]> source.dussan.org Git - aspectj.git/commitdiff
declaremixin
authoraclement <aclement>
Fri, 6 Mar 2009 18:49:55 +0000 (18:49 +0000)
committeraclement <aclement>
Fri, 6 Mar 2009 18:49:55 +0000 (18:49 +0000)
tests/features164/declareMixin/CaseL.java [new file with mode: 0644]
tests/features164/declareMixin/CaseM.java [new file with mode: 0644]
tests/features164/declareMixin/CaseN.java [new file with mode: 0644]
tests/features164/declareMixin/CaseO.java [new file with mode: 0644]
tests/features164/declareMixin/CaseP.java [new file with mode: 0644]
tests/features164/declareMixin/CaseQ.java [new file with mode: 0644]
tests/features164/declareMixin/CaseR.java [new file with mode: 0644]

diff --git a/tests/features164/declareMixin/CaseL.java b/tests/features164/declareMixin/CaseL.java
new file mode 100644 (file)
index 0000000..6c505b9
--- /dev/null
@@ -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 (file)
index 0000000..3127897
--- /dev/null
@@ -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 (file)
index 0000000..54b5f34
--- /dev/null
@@ -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 (file)
index 0000000..4874c16
--- /dev/null
@@ -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 (file)
index 0000000..dc12baa
--- /dev/null
@@ -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 (file)
index 0000000..dedcaba
--- /dev/null
@@ -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 (file)
index 0000000..dc12baa
--- /dev/null
@@ -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");
+  }
+}