]> source.dussan.org Git - aspectj.git/commitdiff
230234 comment 10 - ajdoc modifications and tests
authoraclement <aclement>
Fri, 18 Jul 2008 21:56:31 +0000 (21:56 +0000)
committeraclement <aclement>
Fri, 18 Jul 2008 21:56:31 +0000 (21:56 +0000)
tests/bugs153/GenericMethod/C.java [new file with mode: 0644]
tests/bugs153/StaticImport/C.java [new file with mode: 0644]
tests/bugs153/StaticImport/StaticImport.java [new file with mode: 0644]
tests/bugs153/pr148908/BadInterface.java
tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml

diff --git a/tests/bugs153/GenericMethod/C.java b/tests/bugs153/GenericMethod/C.java
new file mode 100644 (file)
index 0000000..8621aca
--- /dev/null
@@ -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 (file)
index 0000000..fd86d01
--- /dev/null
@@ -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 (file)
index 0000000..7148b84
--- /dev/null
@@ -0,0 +1,5 @@
+package ABC;
+
+public class StaticImport {
+          public enum Alphabet {A, B, C, D;}
+}
index 700f652be880e8a6bbc9286d6ebd6a03df06af83..ea95de3f33db592eb10e33474d603f15bb85e778 100644 (file)
@@ -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;
+       }
+    };
 }
index afe524aba1a05633bf53472e98d6b86f16052084..022bf79dea3d1a5d38883895703c48d052685831 100644 (file)
@@ -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() {
index 28bda322685ecd91e79a30ffd27ccbdd607fdeea..6f50adc1476e1e7471071d3021e53ee7f6e96974 100644 (file)
@@ -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">
          </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