]> source.dussan.org Git - aspectj.git/commitdiff
declaremixin: check signature of factory method
authoraclement <aclement>
Wed, 4 Mar 2009 03:00:29 +0000 (03:00 +0000)
committeraclement <aclement>
Wed, 4 Mar 2009 03:00:29 +0000 (03:00 +0000)
tests/features164/declareMixin/CaseJ.java [new file with mode: 0644]
tests/features164/declareMixin/CaseK.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java
tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml

diff --git a/tests/features164/declareMixin/CaseJ.java b/tests/features164/declareMixin/CaseJ.java
new file mode 100644 (file)
index 0000000..8b33faf
--- /dev/null
@@ -0,0 +1,17 @@
+// TESTING: invalid return type for factory method
+import org.aspectj.lang.annotation.*;
+
+public class CaseJ {
+  public static void main(String[]argv) { }
+}
+
+aspect X {
+  @DeclareMixin("A")
+  public static void createImplementation1() {}
+
+  @DeclareMixin("A")
+  public static int createImplementation2(Object o) {return 2;}
+}
+
+interface I {}
+
diff --git a/tests/features164/declareMixin/CaseK.java b/tests/features164/declareMixin/CaseK.java
new file mode 100644 (file)
index 0000000..c41d736
--- /dev/null
@@ -0,0 +1,15 @@
+// TESTING: too many arguments to the factory method
+import org.aspectj.lang.annotation.*;
+
+public class CaseK {
+  public static void main(String[]argv) { }
+}
+
+aspect X {
+  @DeclareMixin("A")
+  public static I createImplementation1(String s,long foo) {return null;}
+
+}
+
+interface I {}
+
index e18994cb0cfd74dc63127694f6d2b30f03829322..1997c361c486bc8c1d0b1c59e52c31d626a15660 100644 (file)
@@ -21,7 +21,13 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  * In many ways the design is similar to DeclareParents now - so we have to plug in at the same points, but the code generation for
  * generating the delegate object and the choice of which interfaces (and methods within those) to mixin is different.
  * 
- * <h4>Design and test considerations:</h4><br>
+ * <h4>Tested:</h4><br>
+ * <ul>
+ * <li>Factory method with void or primitive return value
+ * <li>Check the factory method has at most one parameter
+ * </ul>
+ * 
+ * <h4>Still to test/explore:</h4><br>
  * <ul>
  * <li>model relationships
  * <li>incremental compilation
@@ -31,7 +37,6 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  * <li>Clashing with existing methods
  * <li>varying parameter type on the factory method
  * <li>See CaseF - what if mixin target is not assignable to the parameter type? create cast?
- * <li>Check the factory method has at most one parameter
  * </ul>
  * 
  * @author Andy Clement
@@ -84,6 +89,16 @@ public class DeclareMixinTests extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("casei");
        }
 
+       // invalid return type for factory method
+       public void testCaseJ() {
+               runTest("casej");
+       }
+
+       // too many arguments to the factory method
+       public void testCaseK() {
+               runTest("casek");
+       }
+
        // --
 
        public static Test suite() {
index a9ed438ba7df5b05088901f659f1677c668948a2..6bf37adfad6b5a3fe7fcf183f3834fe3c763e229 100644 (file)
          <message kind="error" text="Types listed in the 'interfaces'"/>
      </compile>
    </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="casej">
+     <compile files="CaseJ.java" options="-1.5">
+         <message kind="error" text="createImplementation1"/>
+         <message kind="error" text="Method 'int X.createImplementation2(java.lang.Object)':  factory methods "/>
+     </compile>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="casek">
+     <compile files="CaseK.java" options="-1.5">
+         <message kind="error" text="factory methods for a mixin can take a maximum of one parameter"/>
+     </compile>
+   </ajc-test>
         
 </suite>
\ No newline at end of file