]> source.dussan.org Git - aspectj.git/commitdiff
added one simple test for matching members of a parameterized type.
authoracolyer <acolyer>
Mon, 11 Jul 2005 13:48:57 +0000 (13:48 +0000)
committeracolyer <acolyer>
Mon, 11 Jul 2005 13:48:57 +0000 (13:48 +0000)
Took me 3 days to get it to pass!!!

tests/java5/generics/pointcuts/ConcreteImplementingClass.java [new file with mode: 0644]
tests/java5/generics/pointcuts/GenericImplementingClass.java [new file with mode: 0644]
tests/java5/generics/pointcuts/GenericInterface.java [new file with mode: 0644]
tests/java5/generics/pointcuts/RawTypeMatching.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

diff --git a/tests/java5/generics/pointcuts/ConcreteImplementingClass.java b/tests/java5/generics/pointcuts/ConcreteImplementingClass.java
new file mode 100644 (file)
index 0000000..b0446cf
--- /dev/null
@@ -0,0 +1,9 @@
+public class ConcreteImplementingClass 
+implements GenericInterface<Double> {
+       
+       // make sure this method starts on line 5...
+       public int asInt(Double d) {
+               return d.intValue();
+       }
+       
+}
\ No newline at end of file
diff --git a/tests/java5/generics/pointcuts/GenericImplementingClass.java b/tests/java5/generics/pointcuts/GenericImplementingClass.java
new file mode 100644 (file)
index 0000000..89b8d78
--- /dev/null
@@ -0,0 +1,8 @@
+public class GenericImplementingClass<N extends Number>
+ implements GenericInterface<N> {
+        
+        public int asInt(N aNumber) {
+                return aNumber.intValue();
+        }
+        
+ }
\ No newline at end of file
diff --git a/tests/java5/generics/pointcuts/GenericInterface.java b/tests/java5/generics/pointcuts/GenericInterface.java
new file mode 100644 (file)
index 0000000..1092312
--- /dev/null
@@ -0,0 +1,5 @@
+public interface GenericInterface<N extends Number> {
+       
+       int asInt(N aNumber);
+       
+}
diff --git a/tests/java5/generics/pointcuts/RawTypeMatching.aj b/tests/java5/generics/pointcuts/RawTypeMatching.aj
new file mode 100644 (file)
index 0000000..32e80a2
--- /dev/null
@@ -0,0 +1,17 @@
+public aspect RawTypeMatching {
+       
+       // tests that references to a generic or parameterized type are
+       // always matched by a type pattern refering to the raw type form
+       
+       void someCode() {
+               ConcreteImplementingClass cic = new ConcreteImplementingClass();
+               cic.asInt(5.0d);  
+               GenericImplementingClass<Long> gic = new GenericImplementingClass<Long>();
+               gic.asInt(55L);   
+       }
+       
+       declare warning : 
+               execution(* GenericInterface.*(..)) :
+               "execution(* GenericInterface.*(..))";
+       
+}
\ No newline at end of file
index d148b9850d6afad937e4d3e61acfa4ddf1f27c82..fffb6c9b432002e897f547fff25d38876277bbe2 100644 (file)
@@ -177,9 +177,15 @@ public class GenericsTests extends XMLBasedAjcTestCase {
        
        // 1. public ITDs and separate compilation - are the signatures correct for the new public members?
        // 2. ITDF
+
+       // -- Pointcut tests...
        
-       // --- helpers
+       public void testExecutionWithRawType() {
+               runTest("execution pcd with raw type matching");
+       }
        
+       // --- helpers
+               
        // Check the signature attribute on a class is correct
        private void verifyClassSignature(String classname,String sig) {
                try {
@@ -200,5 +206,6 @@ public class GenericsTests extends XMLBasedAjcTestCase {
                        fail("Couldn't find class "+classname+" in the sandbox directory.");
                }
        }
-       
+               
+
 }
index bc11dfeb47b9e16b2f5ecf005d67440935e947ce..fe5f9f5645607b8cbb578547c9516d3d0cd39273 100644 (file)
      <compile files="PR94086.aj" options="-1.5"/>
    </ajc-test>
    
-   // generic bugs
+   <!-- generic bugs -->
    
    <ajc-test dir="java5/generics/bugs" title="ITD method with generic arg">
      <compile files="PR97763.aj" options="-1.5"/>
      <run class="pr100260"/>
    </ajc-test>
    
-   // end of generic bugs
+   <!-- end of generic bugs -->
 
-   // generic aspects
+   <!-- generic aspects -->
    
    <ajc-test dir="java5/generics/genericaspects" title="generic aspects - 1">
      <compile files="GenericAspect1.aj" options="-1.5"/>
      </run>
    </ajc-test>
    
-   // end of generic aspects
-   
-   // generic ITDs
+   <!-- end of generic aspects -->
    
+   <!-- generic ITDs -->
+  
    <ajc-test dir="java5/generics/itds" title="ITDs on generic type">
      <compile files="Parse5.java" options="-1.5">
         <message kind="error" line="9"/>
      <compile files="Parse4.java" options="-1.5"/>
    </ajc-test>
    
-   // end of generic ITDs
+   <!-- end of generic ITDs -->
    
-   // generic decps
+   <!-- generic decps -->
    
    <ajc-test dir="java5/generics/decp" title="generic decp - simple">
      <compile files="Basic.aj" options="-1.5"/>
         <message kind="error" line="11" text="Cannot declare parent I&lt;java.lang.Integer&gt; onto type Basic2 since it already has I&lt;java.lang.String&gt; in its hierarchy"/>
      </compile>
    </ajc-test>
-   
+
    <ajc-test dir="java5/generics/decp" title="generic decp - implementing two variants #2">
      <compile files="Basic2b.aj" options="-1.5">
         <message kind="error" line="10" text="Cannot declare parent I&lt;java.lang.Integer&gt; onto type Basic2b since it already has I in its hierarchy"/>
 
 <!--                 -->
    
  <ajc-test dir="java5/generics/decp" title="generic decp - incorrect number of type parameters">
+ <ajc-test dir="java5/generics/decp" title="generic decp - incorrect number of type parameters">
      <compile files="Basic3.aj" options="-1.5"/>
      <run class="Basic3"/>
    </ajc-test>
    <!--ajc-test dir="java5/generics/decp" title="illegal generic decp">
      <compile files="Basic2.aj" options="-1.5"/>
    </ajc-test-->
+     
+   <!-- end of generic decps -->
+   
+   <!-- generics and  pointcuts -->
+   
+   <ajc-test dir="java5/generics/pointcuts" title="execution pcd with raw type matching">
+     <compile files="GenericInterface.java,ConcreteImplementingClass.java,GenericImplementingClass.java,RawTypeMatching.aj" options="-1.5">
+         <message kind="warning" line="4" text="execution(* GenericInterface.*(..))"/>
+         <message kind="warning" line="5" text="execution(* GenericInterface.*(..))"/>
+     </compile>
+   </ajc-test>
+   
+   <!-- end of generics and pointcuts tests -->
    
-   // end of generic decps
    <!-- ============================================================== -->
    <!--     End of generics tests                                      -->
    <!-- ============================================================== -->