diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs153/GenericMethod/C.java | 14 | ||||
-rw-r--r-- | tests/bugs153/StaticImport/C.java | 8 | ||||
-rw-r--r-- | tests/bugs153/StaticImport/StaticImport.java | 5 | ||||
-rw-r--r-- | tests/bugs153/pr148908/BadInterface.java | 13 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java | 60 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc153/ajc153.xml | 9 |
6 files changed, 103 insertions, 6 deletions
diff --git a/tests/bugs153/GenericMethod/C.java b/tests/bugs153/GenericMethod/C.java new file mode 100644 index 000000000..8621aca45 --- /dev/null +++ b/tests/bugs153/GenericMethod/C.java @@ -0,0 +1,14 @@ +import java.util.List; + +public class C { + public <T> T returnT(T a){ + return a; + } + + public <Q extends List> Q returnQ(Q a){ + return a; + } + + public <T, Q> void doubleGeneric(Q a, T b){ + } +} diff --git a/tests/bugs153/StaticImport/C.java b/tests/bugs153/StaticImport/C.java new file mode 100644 index 000000000..fd86d0162 --- /dev/null +++ b/tests/bugs153/StaticImport/C.java @@ -0,0 +1,8 @@ +package ABC; + +import static ABC.StaticImport.Alphabet.A; +import ABC.StaticImport.*; + +public class C { + protected Alphabet alphabet = A; +} diff --git a/tests/bugs153/StaticImport/StaticImport.java b/tests/bugs153/StaticImport/StaticImport.java new file mode 100644 index 000000000..7148b8471 --- /dev/null +++ b/tests/bugs153/StaticImport/StaticImport.java @@ -0,0 +1,5 @@ +package ABC; + +public class StaticImport { + public enum Alphabet {A, B, C, D;} +} diff --git a/tests/bugs153/pr148908/BadInterface.java b/tests/bugs153/pr148908/BadInterface.java index 700f652be..ea95de3f3 100644 --- a/tests/bugs153/pr148908/BadInterface.java +++ b/tests/bugs153/pr148908/BadInterface.java @@ -1,4 +1,6 @@ import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; public interface BadInterface { @@ -8,4 +10,15 @@ public interface BadInterface { return 0; } }; + + public List<String> aList = new LinkedList<String>() {{ add("Busted"); }}; + + public List<String> bList = new LinkedList<String>() { + public int size() { + for(int i = 0; i < 100; i++) { + return 0; + } + return modCount; + } + }; } diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java index afe524aba..022bf79de 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java @@ -11,6 +11,8 @@ package org.aspectj.systemtest.ajc153; import java.io.File; +import java.util.Iterator; +import java.util.List; import junit.framework.Test; @@ -147,11 +149,21 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase { IHierarchy top = AsmManager.getDefault().getHierarchy(); IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD,"MY_COMPARATOR"); - String expected = "static final Comparator MY_COMPARATOR = new Comparator() {\n" + - " public int compare(Object o1, Object o2) {\n" + - " return 0;\n" + - " }\n" + - "};"; + String expected = "static final Comparator MY_COMPARATOR;\n"; + assertEquals("expected source signature to be " + expected + + " but found " + ipe.getSourceSignature(), + expected, ipe.getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.FIELD,"aList"); + expected = "public List<String> aList;\n"; + assertEquals("expected source signature to be " + expected + + " but found " + ipe.getSourceSignature(), + expected, ipe.getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.FIELD,"bList"); + expected = "public List<String> bList;\n"; assertEquals("expected source signature to be " + expected + " but found " + ipe.getSourceSignature(), expected, ipe.getSourceSignature()); @@ -214,6 +226,44 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testSourceLevelJava6ThrowsUsageError_pr164384() {runTest("source level java 6 throws usage error");} public void testTargetLevelJava6ThrowsUsageError_pr164384() {runTest("target level java 6 throws usage error");} + public void testStaticImport() { + runTest("ensure static import reference have static modifier set"); + IHierarchy top = AsmManager.getDefault().getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.IMPORT_REFERENCE,"ABC.StaticImport.Alphabet.A"); + String expected = "import static ABC.StaticImport.Alphabet.A;"; + assertEquals("expected source signature to be " + expected + + " but found " + ipe.getSourceSignature(), + expected, ipe.getSourceSignature()); + } + + public void testGetSourceSignature_GenericMethods(){ + runTest("ensure getSourceSignature correct with generic method"); + IHierarchy top = AsmManager.getDefault().getHierarchy(); + + IProgramElement ipe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.METHOD,"returnT(T)"); + String expected = "public <T> T returnT(T a)"; + assertEquals("expected source signature to be " + expected + + " but found " + ipe.getSourceSignature(), + expected, ipe.getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.METHOD,"returnQ(Q)"); + expected = "public <Q extends List> Q returnQ(Q a)"; + assertEquals("expected source signature to be " + expected + + " but found " + ipe.getSourceSignature(), + expected, ipe.getSourceSignature()); + + ipe = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.METHOD,"doubleGeneric(Q,T)"); + expected = "public <T, Q> void doubleGeneric(Q a, T b)"; + assertEquals("expected source signature to be " + expected + + " but found " + ipe.getSourceSignature(), + expected, ipe.getSourceSignature()); + } + ///////////////////////////////////////// public static Test suite() { diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml index 28bda3226..6f50adc14 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml +++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml @@ -74,7 +74,7 @@ </ajc-test> <ajc-test dir="bugs153/pr148908" title="ensure getSourceSignature correct with static field"> - <compile files="BadInterface.java" options="-emacssym"/> + <compile files="BadInterface.java" options="-1.5 -emacssym"/> </ajc-test> <ajc-test dir="bugs153/pr161502" title="generics in pointcuts"> @@ -842,4 +842,11 @@ </compile> </ajc-test> + <ajc-test dir="bugs153/StaticImport" title="ensure static import reference have static modifier set"> + <compile files="StaticImport.java,C.java" options="-1.5 -emacssym"/> + </ajc-test> + + <ajc-test dir="bugs153/GenericMethod" title="ensure getSourceSignature correct with generic method"> + <compile files="C.java" options="-1.5 -emacssym"/> + </ajc-test> </suite>
\ No newline at end of file |