aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/features164/declareMixin/CaseL.java20
-rw-r--r--tests/features164/declareMixin/CaseM.java19
-rw-r--r--tests/features164/declareMixin/CaseN.java24
-rw-r--r--tests/features164/declareMixin/CaseO.java24
-rw-r--r--tests/features164/declareMixin/CaseP.java35
-rw-r--r--tests/features164/declareMixin/CaseQ.java32
-rw-r--r--tests/features164/declareMixin/CaseR.java35
7 files changed, 189 insertions, 0 deletions
diff --git a/tests/features164/declareMixin/CaseL.java b/tests/features164/declareMixin/CaseL.java
new file mode 100644
index 000000000..6c505b944
--- /dev/null
+++ b/tests/features164/declareMixin/CaseL.java
@@ -0,0 +1,20 @@
+// TESTING: mixin of a class - should be an error
+import org.aspectj.lang.annotation.*;
+
+public class CaseL {
+ public static void main(String[]argv) {
+ ((C)new CaseL()).foo();
+ }
+}
+
+aspect X {
+ @DeclareMixin("CaseL")
+ public static C createImplementation1() {return new C();}
+
+}
+
+class C {
+ void foo() {
+ System.out.println("foo() running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseM.java b/tests/features164/declareMixin/CaseM.java
new file mode 100644
index 000000000..31278979d
--- /dev/null
+++ b/tests/features164/declareMixin/CaseM.java
@@ -0,0 +1,19 @@
+// TESTING: mixin of a class - should be an error
+import org.aspectj.lang.annotation.*;
+
+public class CaseM {
+ public static void main(String[]argv) {
+ }
+}
+
+aspect X {
+ @DeclareMixin("CaseM")
+ public static C createImplementation1() {return new C();}
+
+}
+
+class C {
+ void foo() {
+ System.out.println("foo() running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseN.java b/tests/features164/declareMixin/CaseN.java
new file mode 100644
index 000000000..54b5f34dd
--- /dev/null
+++ b/tests/features164/declareMixin/CaseN.java
@@ -0,0 +1,24 @@
+// TESTING: factory returns class but interface specified - this is OK
+import org.aspectj.lang.annotation.*;
+
+public class CaseN {
+ public static void main(String[]argv) {
+ ((I)new CaseN()).foo();
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseN",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+class C implements I {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseO.java b/tests/features164/declareMixin/CaseO.java
new file mode 100644
index 000000000..4874c1638
--- /dev/null
+++ b/tests/features164/declareMixin/CaseO.java
@@ -0,0 +1,24 @@
+// TESTING: factory returns class but interface specified - not ok as class doesn't implement interface
+import org.aspectj.lang.annotation.*;
+
+public class CaseO {
+ public static void main(String[]argv) {
+ ((I)new CaseO()).foo();
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseO",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+class C {
+ void foo() {
+ System.out.println("foo() running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseP.java b/tests/features164/declareMixin/CaseP.java
new file mode 100644
index 000000000..dc12baa4e
--- /dev/null
+++ b/tests/features164/declareMixin/CaseP.java
@@ -0,0 +1,35 @@
+// TESTING: interface subsetting used (factory returns class) - but only one method should be delegated
+import org.aspectj.lang.annotation.*;
+
+public class CaseP {
+ public static void main(String[]argv) {
+ ((I)new CaseP()).foo();
+ CaseP cp = new CaseP();
+ if (cp instanceof J) { // should not have been mixed in
+ throw new RuntimeException();
+ }
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseP",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+interface J {
+ void goo();
+}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseQ.java b/tests/features164/declareMixin/CaseQ.java
new file mode 100644
index 000000000..dedcabae9
--- /dev/null
+++ b/tests/features164/declareMixin/CaseQ.java
@@ -0,0 +1,32 @@
+// TESTING: factory return type implements two interfaces, both should be mixed as specified
+import org.aspectj.lang.annotation.*;
+
+public class CaseQ {
+ public static void main(String[]argv) {
+ ((I)new CaseQ()).foo();
+ ((J)new CaseQ()).goo();
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseQ",interfaces={I.class,J.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+interface J {
+ void goo();
+}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}
diff --git a/tests/features164/declareMixin/CaseR.java b/tests/features164/declareMixin/CaseR.java
new file mode 100644
index 000000000..dc12baa4e
--- /dev/null
+++ b/tests/features164/declareMixin/CaseR.java
@@ -0,0 +1,35 @@
+// TESTING: interface subsetting used (factory returns class) - but only one method should be delegated
+import org.aspectj.lang.annotation.*;
+
+public class CaseP {
+ public static void main(String[]argv) {
+ ((I)new CaseP()).foo();
+ CaseP cp = new CaseP();
+ if (cp instanceof J) { // should not have been mixed in
+ throw new RuntimeException();
+ }
+ }
+}
+
+aspect X {
+ @DeclareMixin(value="CaseP",interfaces={I.class})
+ public static C createImplementation1() {return new C();}
+
+}
+
+interface I {
+ void foo();
+}
+
+interface J {
+ void goo();
+}
+
+class C implements I,J {
+ public void foo() {
+ System.out.println("foo() running");
+ }
+ public void goo() {
+ System.out.println("goo() running");
+ }
+}