summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2009-03-04 03:00:29 +0000
committeraclement <aclement>2009-03-04 03:00:29 +0000
commita717f689d51d8392d1f81e50556e25f26658294f (patch)
treea44cad48a1c033c83c2de16ddcde53e60aa34fd1
parentb331fa862e3296cb26b3d6b47a5c8a4dfe2110a8 (diff)
downloadaspectj-a717f689d51d8392d1f81e50556e25f26658294f.tar.gz
aspectj-a717f689d51d8392d1f81e50556e25f26658294f.zip
declaremixin: check signature of factory method
-rw-r--r--tests/features164/declareMixin/CaseJ.java17
-rw-r--r--tests/features164/declareMixin/CaseK.java15
-rw-r--r--tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java19
-rw-r--r--tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml13
4 files changed, 62 insertions, 2 deletions
diff --git a/tests/features164/declareMixin/CaseJ.java b/tests/features164/declareMixin/CaseJ.java
new file mode 100644
index 000000000..8b33faf6c
--- /dev/null
+++ b/tests/features164/declareMixin/CaseJ.java
@@ -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
index 000000000..c41d7363b
--- /dev/null
+++ b/tests/features164/declareMixin/CaseK.java
@@ -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 {}
+
diff --git a/tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java b/tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java
index e18994cb0..1997c361c 100644
--- a/tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java
@@ -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() {
diff --git a/tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml b/tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml
index a9ed438ba..6bf37adfa 100644
--- a/tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml
+++ b/tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml
@@ -89,5 +89,18 @@
<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