aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-08-09 13:04:57 +0000
committeracolyer <acolyer>2005-08-09 13:04:57 +0000
commit0a1b33eeb5d154b81a6d060670d49df6f6d8b81e (patch)
tree390a99df8fde40b2bee5ec053011613e81a52133
parent4a9396dc60a8ffd6e1864b1c0e3122f13ebbd529 (diff)
downloadaspectj-0a1b33eeb5d154b81a6d060670d49df6f6d8b81e.tar.gz
aspectj-0a1b33eeb5d154b81a6d060670d49df6f6d8b81e.zip
tests for args - this completes the implementation of generic and parameterized type matching for ALL pointcuts in AspectJ 5. yay.
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java95
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml129
2 files changed, 191 insertions, 33 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
index 593a66679..a16a6f300 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
@@ -64,11 +64,23 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* - instanceof
* target PASS
* - as this
- * args TODO
- * - as this/target, plus...
- * - known static match
- * - known static match fail
- * - maybe match with unchecked warning
+ * args
+ * - args(List) matches List, List<T>, List<String> PASS
+ * - args(List<T>) -> invalid absolute type T
+ * - args(List<String>) matches List<String> but not List<Number> PASS
+ * - args(List<String>) matches List with unchecked warning PASS
+ * - args(List<String>) matches List<?> with unchecked warning PASS
+ * - args(List<Double>) matches List, List<?>, List<? extends Number> with unchecked warning PASS
+ * matches List<Double> PASS, List<? extends Double> PASS(with warning)
+ * - args(List<?>) matches List, List<String>, List<?>, ... PASS
+ * - args(List<? extends Number) matches List<Number>, List<Double>, not List<String> PASS
+ * matches List, List<?> with unchecked warning PASS
+ * - args(List<? super Number>) matches List<Object>, List<Number>
+ * does not match List<Double>
+ * matches List, List<?> with unchecked warning
+ * matches List<? super Number>
+ * matches List<? extends Object> with unchecked warning
+ * matches List<? extends Number> with unchecked warning
* get & set PASS
* - parameterized declaring type PASS
* - generic declaring type PASS
@@ -95,14 +107,16 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* - parameter as type variable PASS
* - parameter as parameterized type PASS
* - no join points for bridge methods PASS
- * call
- * - no generic or parameterized declaring type patterns
- * - no parameterized throws patterns
- * - return type as type variable
- * - return type as parameterized type
- * - parameter as type variable
- * - parameter as parameterized type
- * - a call to a bridge method is really a call to the method being bridged... (1.4/1.5 differences here?)
+ * call PASS
+ * - no generic or parameterized declaring type patterns PASS
+ * - no parameterized throws patterns PASS
+ * - return type as type variable PASS
+ * - return type as parameterized type PASS
+ * - parameter as type variable PASS
+ * - parameter as parameterized type PASS
+ * - calls to a bridge methods PASS
+ * after throwing - can't use parameterized type pattern
+ * after returning - same as for args
*/
/* ==========================================
@@ -206,6 +220,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
// parsing of generic ITD members
+
public void testParseItdNonStaticMethod() {runTest("Parsing generic ITDs - 1");}
public void testParseItdStaticMethod() {runTest("Parsing generic ITDs - 2");}
public void testParseItdCtor() {runTest("Parsing generic ITDs - 3");}
@@ -213,14 +228,15 @@ public class GenericsTests extends XMLBasedAjcTestCase {
// public void testParseItdSharingVars1() {runTest("Parsing generic ITDs - 5");}
// public void testParseItdSharingVars2() {runTest("Parsing generic ITDs - 6");}
-
+
// non static
- public void testGenericMethodITD1() {runTest("generic method itd - 1");} // <E> ... (List<? extends E>)
- public void testGenericMethodITD2() {runTest("generic method itd - 2");} // <E extends Number> ... (List<? extends E>) called incorrectly
- public void testGenericMethodITD3() {runTest("generic method itd - 3");} // <E> ... (List<E>,List<E>)
- public void testGenericMethodITD4() {runTest("generic method itd - 4");} // <A,B> ... (List<A>,List<B>)
- public void testGenericMethodITD5() {runTest("generic method itd - 5");} // <E> ... (List<E>,List<E>) called incorrectly
- public void testGenericMethodITD6() {runTest("generic method itd - 6");} // <E extends Number> ... (List<? extends E>)
+
+ public void testGenericMethodITD1() {runTest("generic method itd - 1");} // <E> ... (List<? extends E>)
+ public void testGenericMethodITD2() {runTest("generic method itd - 2");} // <E extends Number> ... (List<? extends E>) called incorrectly
+ public void testGenericMethodITD3() {runTest("generic method itd - 3");} // <E> ... (List<E>,List<E>)
+ public void testGenericMethodITD4() {runTest("generic method itd - 4");} // <A,B> ... (List<A>,List<B>)
+ public void testGenericMethodITD5() {runTest("generic method itd - 5");} // <E> ... (List<E>,List<E>) called incorrectly
+ public void testGenericMethodITD6() {runTest("generic method itd - 6");} // <E extends Number> ... (List<? extends E>)
public void testGenericMethodITD7() {runTest("generic method itd - 7"); } // <E> ... (List<E>,List<? extends E>)
public void testGenericMethodITD8() {runTest("generic method itd - 8"); } // <E> ... (List<E>,List<? extends E>) called incorrectly
public void testGenericMethodITD9() {runTest("generic method itd - 9"); } // <R extends Comparable<? super R>> ... (List<R>)
@@ -232,7 +248,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testGenericMethodITD15() {runTest("generic method itd - 15");} // <R extends Comparable<? super R>> ... (List<R>) called correctly in a clever way
-
+
// generic ctors
public void testGenericCtorITD1() {runTest("generic ctor itd - 1");} // <T> new(List<T>)
public void testGenericCtorITD2() {runTest("generic ctor itd - 2");} // <T> new(List<T>,List<? extends T>)
@@ -495,14 +511,37 @@ public class GenericsTests extends XMLBasedAjcTestCase {
runTest("get and set with various parameterizations and generic field types");
}
-// public void testExecutionWithGenericDeclaringTypeAndErasedParameterTypes() {
-// runTest("execution pcd with generic declaring type and erased parameter types");
-// }
+ public void testArgsWithRawType() {
+ runTest("args with raw type and generic / parameterized sigs");
+ }
-// not passing yet...
-// public void testExecutionWithGenericSignature() {
-// runTest("execution pcd with generic signature matching");
-// }
+ public void testArgsParameterizedType() {
+ runTest("args with parameterized type and generic / parameterized sigs");
+ }
+
+ public void testArgsParameterizedAndWildcards() {
+ runTest("args with parameterized type and wildcards");
+ }
+
+ public void testArgsWithWildcardVar() {
+ runTest("args with generic wildcard");
+ }
+
+ public void testArgsWithWildcardExtendsVar() {
+ runTest("args with generic wildcard extends");
+ }
+
+ public void testArgsWithWildcardSuperVar() {
+ runTest("args with generic wildcard super");
+ }
+
+ public void testGenericMethodMatching() {
+ runTest("generic method matching");
+ }
+
+ public void testGenericWildcardsInSignatureMatching() {
+ runTest("generic wildcards in signature matching");
+ }
// --- helpers
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index 958df1395..1605cccf4 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -2610,7 +2610,7 @@
<ajc-test dir="java5/generics/itds" title="Parsing generic ITDs - 4">
<compile files="Parse4.java" options="-1.5"/>
</ajc-test>
-
+
<ajc-test dir="java5/generics/itds" title="Parsing generic ITDs - 5">
<compile files="Parse5.java" options="-1.5"/>
</ajc-test>
@@ -2883,6 +2883,7 @@
<message kind="warning" line="84" text="the really wild show"/>
<message kind="warning" line="86" text="the really wild show"/>
<message kind="warning" line="88" text="the really wild show"/>
+ <message kind="warning" line="53" text="the really wild show"/>
</compile>
</ajc-test>
@@ -3083,6 +3084,124 @@
</compile>
</ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="args with raw type and generic / parameterized sigs">
+ <compile files="RawArgs.aj" options="-1.5">
+ </compile>
+ <run class="RawArgs">
+ <stdout>
+ <line text="args(List) match at call(void Generic.foo(List))"/>
+ <line text="args(List) match at call(void Generic.bar(List))"/>
+ <line text="args(List) match at call(void Generic.tada(List))"/>
+ <line text="args(List) match at call(void Generic.tada(List))"/>
+ <line text="args(List) match at call(void Generic.tada(List))"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="args with parameterized type and generic / parameterized sigs">
+ <compile files="ArgsParameterized.aj" options="-1.5">
+ <message kind="warning" line="28" text="unchecked match of List&lt;String&gt; with List"/>
+ </compile>
+ <run class="ArgsParameterized">
+ <stdout>
+ <line text="args(List&lt;String&gt; matched at call(void Generic.foo(List))"/>
+ <line text="args(List&lt;String&gt; matched at call(void Generic.bar(List))"/>
+ <line text="args(List&lt;String&gt; matched at call(void Generic.tada(List))"/>
+ <line text="args(List&lt;String&gt; matched at call(void Generic.something(List))"/>
+ <line text="args(List&lt;String&gt; matched at call(void MustBeString.listit(List))"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="args with parameterized type and wildcards">
+ <compile files="ArgsParameterizedWithWildcards.aj" options="-1.5">
+ <message kind="warning" line="10" text="unchecked match of List&lt;Double&gt; with List&lt;? extends Double&gt; when argument is an instance of List"/>
+ <message kind="warning" line="10" text="unchecked match of List&lt;Double&gt; with List&lt;? extends Number&gt; when argument is an instance of List"/>
+ <message kind="warning" line="10" text="unchecked match of List&lt;Double&gt; with List&lt;?&gt; when argument is an instance of List"/>
+ </compile>
+ <run class="ArgsParameterizedWithWildcards">
+ <stdout>
+ <line text="List&lt;Double&gt; matched at execution(void C.rawList(List))"/>
+ <line text="List&lt;Double&gt; matched at execution(void C.listOfSomething(List))"/>
+ <line text="List&lt;Double&gt; matched at execution(void C.listOfSomeNumber(List))"/>
+ <line text="List&lt;Double&gt; matched at execution(void C.listOfDouble(List))"/>
+ <line text="List&lt;Double&gt; matched at execution(void C.listOfSomeDouble(List))"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="args with generic wildcard">
+ <compile files="ArgsListOfSomething.aj" options="-1.5">
+ </compile>
+ <run class="ArgsListOfSomething">
+ <stdout>
+ <line text="List&lt;?&gt; matches execution(void ArgsListOfSomething.rawList(List))"/>
+ <line text="List&lt;?&gt; matches execution(void ArgsListOfSomething.listOfString(List))"/>
+ <line text="List&lt;?&gt; matches execution(void ArgsListOfSomething.listOfSomething(List))"/>
+ <line text="List&lt;?&gt; matches execution(void ArgsListOfSomething.listOfSomethingExtends(List))"/>
+ <line text="List&lt;?&gt; matches execution(void ArgsListOfSomething.listOfSomethingSuper(List))"/>
+ <line text="wild map matches execution(void ArgsListOfSomething.mapit(Map))"/>
+ <line text="exact wild map matches execution(void ArgsListOfSomething.mapit(Map))"/>
+ <line text="super type exact matches execution(void ArgsListOfSomething.setOf(HashSet))"/>
+ <line text="super wild type matches execution(void ArgsListOfSomething.setOf(HashSet))"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="args with generic wildcard extends">
+ <compile files="ArgsListOfSomethingExtends.aj" options="-1.5">
+ <message kind="warning" line="27" text="unchecked match of List&lt;? extends Number&gt; with List"/>
+ <message kind="warning" line="27" text="unchecked match of List&lt;? extends Number&gt; with List&lt;?&gt;"/>
+ </compile>
+ <run class="ArgsListOfSomethingExtends">
+ <stdout>
+ <line text="List&lt;? extends Number&gt; matches execution(void ArgsListOfSomethingExtends.rawList(List))"/>
+ <line text="List&lt;? extends Number&gt; matches execution(void ArgsListOfSomethingExtends.listOfNumber(List))"/>
+ <line text="List&lt;? extends Number&gt; matches execution(void ArgsListOfSomethingExtends.listOfDouble(List))"/>
+ <line text="List&lt;? extends Number&gt; matches execution(void ArgsListOfSomethingExtends.listOfSomething(List))"/>
+ <line text="List&lt;? extends Number&gt; matches execution(void ArgsListOfSomethingExtends.listOfSomethingExtends(List))"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="args with generic wildcard super">
+ <compile files="ArgsListOfSomethingSuper.aj" options="-1.5">
+ <message kind="warning" line="32" text="unchecked match of List&lt;? super Number&gt; with List"/>
+ <message kind="warning" line="32" text="unchecked match of List&lt;? super Number&gt; with List&lt;?&gt;"/>
+ <message kind="warning" line="32" text="unchecked match of List&lt;? super Number&gt; with List&lt;? extends Number&gt;"/>
+ </compile>
+ <run class="ArgsListOfSomethingSuper">
+ <stdout>
+ <line text="List&lt;? super Number&gt; matches execution(void ArgsListOfSomethingSuper.rawList(List))"/>
+ <line text="List&lt;? super Number&gt; matches execution(void ArgsListOfSomethingSuper.listOfObject(List))"/>
+ <line text="List&lt;? super Number&gt; matches execution(void ArgsListOfSomethingSuper.listOfNumber(List))"/>
+ <line text="List&lt;? super Number&gt; matches execution(void ArgsListOfSomethingSuper.listOfSomething(List))"/>
+ <line text="List&lt;? super Number&gt; matches execution(void ArgsListOfSomethingSuper.listOfSomethingSuper(List))"/>
+ <line text="List&lt;? super Number&gt; matches execution(void ArgsListOfSomethingSuper.listOfSomethingExtendsNumber(List))"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="generic method matching">
+ <compile files="GenericMethods.aj" options="-1.5">
+ <message kind="warning" line="19" text="static generic method match"/>
+ <message kind="warning" line="34" text="static generic method match"/>
+ <message kind="warning" line="24" text="instance generic method match"/>
+ <message kind="warning" line="39" text="instance generic method match"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="java5/generics/pointcuts" title="generic wildcards in signature matching">
+ <compile files="GenericWildcardsInSignatureMatching.aj" options="-1.5">
+ <message kind="warning" line="5" text="set of a list"/>
+ <message kind="warning" line="7" text="exact nested wildcard match"/>
+ <message kind="warning" line="7" text="wildcard nested wildcard match"/>
+ <message kind="warning" line="11" text="super"/>
+ <message kind="warning" line="15" text="super wild match"/>
+ </compile>
+ </ajc-test>
+
<!-- end of generics and pointcuts tests -->
@@ -3316,7 +3435,7 @@
</run>
</ajc-test>
-<ajc-test dir="bugs150/pr98901" title="public ITD field with declare @field">
+ <ajc-test dir="bugs150/pr98901" title="public ITD field with declare @field">
<compile files="Case26.aj" options="-1.5 -Xlint:error"/>
<run class="B26">
<stdout>
@@ -3325,7 +3444,7 @@
</run>
</ajc-test>
-<ajc-test dir="bugs150/pr98901" title="public annotated ITD field">
+ <ajc-test dir="bugs150/pr98901" title="public annotated ITD field">
<compile files="Case27.aj" options="-1.5 -Xlint:error"/>
<run class="B27">
<stdout>
@@ -3334,7 +3453,7 @@
</run>
</ajc-test>
-<ajc-test dir="bugs150/pr98901" title="public ITD-on-itself field with declare @field">
+ <ajc-test dir="bugs150/pr98901" title="public ITD-on-itself field with declare @field">
<compile files="Case28.aj" options="-1.5 -Xlint:error"/>
<run class="B28">
<stdout>
@@ -3343,7 +3462,7 @@
</run>
</ajc-test>
-<ajc-test dir="bugs150/pr98901" title="public annotated ITD-on-itself field">
+ <ajc-test dir="bugs150/pr98901" title="public annotated ITD-on-itself field">
<compile files="Case29.aj" options="-1.5 -Xlint:error"/>
<run class="B29">
<stdout>