]> source.dussan.org Git - aspectj.git/commitdiff
GenericsWork: ITD testcode
authoraclement <aclement>
Thu, 2 Jun 2005 11:09:21 +0000 (11:09 +0000)
committeraclement <aclement>
Thu, 2 Jun 2005 11:09:21 +0000 (11:09 +0000)
12 files changed:
tests/java5/generics/bugs/PR95992.java [new file with mode: 0644]
tests/java5/generics/decp/Basic.aj [new file with mode: 0644]
tests/java5/generics/decp/Basic2.aj [new file with mode: 0644]
tests/java5/generics/itds/A.java [new file with mode: 0644]
tests/java5/generics/itds/B.java [new file with mode: 0644]
tests/java5/generics/itds/C.java [new file with mode: 0644]
tests/java5/generics/itds/D.java [new file with mode: 0644]
tests/java5/generics/itds/Parse1.java [new file with mode: 0644]
tests/java5/generics/itds/Parse2.java [new file with mode: 0644]
tests/java5/generics/itds/Parse3.java [new file with mode: 0644]
tests/java5/generics/itds/Parse4.java [new file with mode: 0644]
tests/java5/generics/itds/Parse5.java [new file with mode: 0644]

diff --git a/tests/java5/generics/bugs/PR95992.java b/tests/java5/generics/bugs/PR95992.java
new file mode 100644 (file)
index 0000000..824967f
--- /dev/null
@@ -0,0 +1,8 @@
+interface Base<T> {
+    static interface Inner {
+    }
+}
+class Test<T extends Test.InnerTest> implements Base<T> {
+    static class InnerTest implements Inner {
+    }
+}
diff --git a/tests/java5/generics/decp/Basic.aj b/tests/java5/generics/decp/Basic.aj
new file mode 100644 (file)
index 0000000..dee3872
--- /dev/null
@@ -0,0 +1,13 @@
+interface I<T>{ }
+
+public class Basic{
+
+  public static void main(String[]argv) {
+    Basic b = new Basic();
+    if (b instanceof I) throw new RuntimeException("Should implement I??");
+  }
+}
+
+aspect X{
+    declare parents: Basic implements I<String>;
+}
diff --git a/tests/java5/generics/decp/Basic2.aj b/tests/java5/generics/decp/Basic2.aj
new file mode 100644 (file)
index 0000000..d1127d1
--- /dev/null
@@ -0,0 +1,12 @@
+// error, can't implement two variants of a generic type
+interface I<T>{ }
+
+public class Basic implements I<String> {
+
+  public static void main(String[]argv) {
+  }
+}
+
+aspect X{
+    declare parents: Basic implements I<Integer>; // error
+}
diff --git a/tests/java5/generics/itds/A.java b/tests/java5/generics/itds/A.java
new file mode 100644 (file)
index 0000000..f75d7f9
--- /dev/null
@@ -0,0 +1,21 @@
+public class A {
+  public static void main(String[] argv) {
+    Integer two = 2;
+    Integer four= 4;
+    System.err.println("min(2,4)=>"+ new Utils().min(two,four));
+    System.err.println("max(2,4)=>"+new Utils().max(two,four));
+  }
+}
+
+
+aspect X {
+  <T extends Number> T Utils.max(T first,T second) {
+    if (first>second) return first; else return second;
+  }
+}
+
+class Utils {
+  <T extends Number> T min(T first,T second) {
+    if (first.intValue()<second.intValue()) return first; else return second;
+  }
+}
diff --git a/tests/java5/generics/itds/B.java b/tests/java5/generics/itds/B.java
new file mode 100644 (file)
index 0000000..321d828
--- /dev/null
@@ -0,0 +1,21 @@
+public class B {
+  public static void main(String[] argv) {
+    Integer two = 2;
+    Integer four= 4;
+    System.err.println("min(2,4)=>"+ Utils.min(two,four));
+    System.err.println("max(2,4)=>"+Utils.max(two,four));
+  }
+}
+
+
+aspect X {
+  static <T extends Number> T Utils.max(T first,T second) {
+    if (first>second) return first; else return second;
+  }
+}
+
+class Utils {
+  static <T extends Number> T min(T first,T second) {
+    if (first.intValue()<second.intValue()) return first; else return second;
+  }
+}
diff --git a/tests/java5/generics/itds/C.java b/tests/java5/generics/itds/C.java
new file mode 100644 (file)
index 0000000..536b6a8
--- /dev/null
@@ -0,0 +1,8 @@
+// Using type parameter in ITD 
+public abstract aspect C<T> {
+  private T Foo.data;
+
+  public T Foo.getData(T defaultValue) {
+    return (this.data!=null?data:defaultValue);
+  }
+}
diff --git a/tests/java5/generics/itds/D.java b/tests/java5/generics/itds/D.java
new file mode 100644 (file)
index 0000000..2ab496c
--- /dev/null
@@ -0,0 +1,11 @@
+public abstract aspect D<T> {
+              
+  private T Goo<T>.data;
+            
+  public T Goo<T>.getData(T defaultValue) {
+    return (this.data != null ? data : defaultValue);
+  }   
+                
+}
+
+class Goo<P> {}
diff --git a/tests/java5/generics/itds/Parse1.java b/tests/java5/generics/itds/Parse1.java
new file mode 100644 (file)
index 0000000..7168e15
--- /dev/null
@@ -0,0 +1,6 @@
+// Simple non-static ITDM
+public class Parse1 { }
+
+aspect X {
+  <T> T Parse1.m(T) {} 
+}
diff --git a/tests/java5/generics/itds/Parse2.java b/tests/java5/generics/itds/Parse2.java
new file mode 100644 (file)
index 0000000..2764904
--- /dev/null
@@ -0,0 +1,6 @@
+// Simple static ITDM
+public class Parse2 { }
+
+aspect X {
+  static <T> T Parse2.m(T) {} 
+}
diff --git a/tests/java5/generics/itds/Parse3.java b/tests/java5/generics/itds/Parse3.java
new file mode 100644 (file)
index 0000000..2b9aab4
--- /dev/null
@@ -0,0 +1,6 @@
+// Simple ITDC
+public class Parse1 { }
+
+aspect X {
+  <T> T Parse1.new(T) {} 
+}
diff --git a/tests/java5/generics/itds/Parse4.java b/tests/java5/generics/itds/Parse4.java
new file mode 100644 (file)
index 0000000..685356e
--- /dev/null
@@ -0,0 +1,8 @@
+import java.util.*;
+
+// Complex ITDM
+public class Parse1 { }
+
+aspect X {
+  <T> Parse1.sort(List<T> elements,Comparator<? super T> comparator) {}
+}
diff --git a/tests/java5/generics/itds/Parse5.java b/tests/java5/generics/itds/Parse5.java
new file mode 100644 (file)
index 0000000..c322f00
--- /dev/null
@@ -0,0 +1,16 @@
+// ITDs on generic types
+public class Parse5<T,S extends Number> {}
+
+aspect X {
+  String Parse5.m1() {}
+
+  String Parse5<Q,R extends Number>.m2() {}
+
+  String Parse5<T,V>.m3() {} // error
+  String Parse5<A,B extends Number,C>.m4() {} // error
+
+  String Parse5<A>.m5() {} // error
+  
+  String Parse5<String,Integer>.m6() {} // error
+}