From da08b5a5c309ea75fe64c5394bf9e2d88268aef5 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 9 Dec 2008 21:06:08 +0000 Subject: [PATCH] more tests --- .../aspectj/weaver/ReferenceTypeTestCase.java | 395 ++++++++++-------- 1 file changed, 226 insertions(+), 169 deletions(-) diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java index 7af73d784..6377b693a 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java @@ -471,178 +471,235 @@ public class ReferenceTypeTestCase extends TestCase { ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); - // - // // void around(): execution(* C.m4(..)) && args(List){} //: - // Should not match (but it does) ERROR - // // void around(): execution(* C.m4(..)) && args(ArrayList){}//: - // Should not match (but it does) ERROR - // // void around(): execution(* C.m4(..)) && args(List){}//: Should - // not match (but it does) ERROR - // // void around(): execution(* C.m4(..)) && args(ArrayList){}//: - // Should not match (but it does) ERROR - // // void around(): execution(* C.m4(..)) && args(List){}//: Should not match (but it does) ERROR - // // void around(): execution(* C.m4(..)) && args(ArrayList){}//: Should not match (but it does!) ERROR - // // void around(): execution(* C.m4(..)) && args(List){}//: Should match - // (it does) - // // void around(): execution(* C.m4(..)) && args(ArrayList){}//: Should - // runtime check (it does!) - // // void around(): execution(* C.m4(..)) && args(List){}//: Should - // match (it does) - // // void around(): execution(* C.m4(..)) && args(ArrayList){}//: Should - // runtime check (it does!) - // // void around(): execution(* C.m4(..)) && args(ArrayList){}//: - // Should not match (it does not match!) - // - // // void around(): execution(* C.m5(..)) && args(List){} //: - // Should not match (but it does) ERROR - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: - // Should not match (but it does!) ERROR - // // void around(): execution(* C.m5(..)) && args(List){}//: Should - // not match (but it does!) ERROR - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: - // Should not match (it does) ERROR - // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // void around(): execution(* C.m5(..)) && args(List){}//: Should match - // (it does) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should - // runtime check (it does not match!) ERROR - // // void around(): execution(* C.m5(..)) && args(List){}//: Should - // match (it does) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should - // runtime check (it does not match!) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: - // Should not match (it does not match!) - // - // // void around(): execution(* D2.m5(..)) && args(List){} //: Should - // not match (but it does) ERROR - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // Should not match (but it does!) ERROR - // // void around(): execution(* D2.m5(..)) && args(List){}//: Should - // not match (but it does!) ERROR - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // Should not match (it does) ERROR - // // void around(): execution(* D2.m5(..)) && args(List){}//: - // Should match (it does) - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // void around(): execution(* D2.m5(..)) && args(List){}//: - // Should match (it does) - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // void around(): execution(* D2.m5(..)) && args(List){}//: Should match - // (it does) - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should - // runtime check (it does not match!) ERROR - // // void around(): execution(* D2.m5(..)) && args(List){}//: Should - // match (it does) - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // Should runtime check (it does not match!) - // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // Should not match (it does not match!) - // - // // void around(): execution(* C.m6(..)) && args(List){} //: - // Should not match (but it does) ERROR - // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: - // Should not match (but it does!) ERROR - // // void around(): execution(* C.m6(..)) && args(List){}//: Should - // not match (but it does!) ERROR - // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: - // Should not match (it does) ERROR - // // void around(): execution(* C.m6(..)) && args(List){}//: Should match (it does) - // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // void around(): execution(* C.m6(..)) && args(List){}//: Should match - // (it does) - // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should - // runtime check (it does not match!) - // // void around(): execution(* C.m6(..)) && args(List){}//: Should - // match (it does) - // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should - // runtime check (it does not match!) - // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: - // Should not match (it does not match!) - // - // // void around(): execution(* C.m7(..)) && args(List>){} - // //: Should not match (but it does) ERROR - // // void around(): execution(* C.m7(..)) && - // args(ArrayList>){}//: Should not match (but it does!) ERROR - // // void around(): execution(* C.m7(..)) && args(List>){}//: - // Should not match (but it does!) ERROR - // // void around(): execution(* C.m7(..)) && - // args(ArrayList>){}//: Should not match (but it does) ERROR - // // void around(): execution(* C.m7(..)) && args(List>){}//: Should not match (but it does) ERROR - // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends - // List>){}//: Should not match (but it does!) ERROR - // // void around(): execution(* C.m7(..)) && args(List< ? extends List>){}//: Should match (it does!) - // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends - // List>){}//: Should match (it does!) - // // void around(): execution(* C.m7(..)) && args(List){}//: Should match - // (it does) - // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should - // runtime check (it does not match!) - // // void around(): execution(* C.m7(..)) && args(List){}//: Should - // match (it does) - // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should - // runtime check (it does!) - // // void around(): execution(* C.m7(..)) && - // args(ArrayList>){}//: Should not match (it does not match!) - // - // // void around(): execution(* C.m8(..)) && args(List){} //: - // Should match with unchecked conversion (it does) - // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: - // Should runtime check with unchecked conversion (it does!) - // // void around(): execution(* C.m8(..)) && args(List){}//: Should - // match with unchecked conversion (it does!) - // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: - // Should runtime check with unchecked conversion (it does) - // // void around(): execution(* C.m8(..)) && args(List){}//: Should match with unchecked conversion (it does!) - // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should runtime check with unchecked conversion (it does) - // // void around(): execution(* C.m8(..)) && args(List){}//: Should match - // (it does) - // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should - // runtime check (it does!) - // // void around(): execution(* C.m8(..)) && args(List){}//: Should - // match (it does) - // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should - // runtime check (it does!) - // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: - // Should not match (it does not match!) - // - // // void around(): execution(* C.m9(..)) && args(List){} //: - // Should not match (but it does) ERROR - // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: - // Should not match (it does not match!) - // // void around(): execution(* C.m9(..)) && args(Number){}//: Should match - // (it does!) - // // void around(): execution(* C.m9(..)) && args(Integer){}//: Should - // runtime check (it does) - // // void around(): execution(* C.m9(..)) && args(List){}//: Should not match (but it does) ERROR - // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should not match (it does not match!) - // // void around(): execution(* C.m9(..)) && args(List){}//: Should not - // match (but it does) ERROR - // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should - // not match (it does not match!) - // // void around(): execution(* C.m9(..)) && args(List){}//: Should not - // match (but it does) ERROR - // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should - // not match (it does not match!) - // // void around(): execution(* C.m9(..)) && args(String){}//: Should not - // match (it does not match!) + // void m4(List e) {} + + // void around(): execution(* C.m4(..)) && args(List){} //: Should match with unchecked warning + listOfInteger = (List) listOfSomething; + assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomething)); + assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning + arraylistOfInteger = (ArrayList) listOfSomething; + assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomething)); + assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(List){} // Should match with unchecked warning + listOfNumber = (List) listOfSomething; + assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomething)); + assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning + arrayListOfNumber = (ArrayList) listOfSomething; + assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomething)); + assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(List){} // Should match with unchecked warning + listOfSomethingNumberish = (List) listOfSomething; + assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething)); + assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning + arrayListOfSomethingNumberish = (ArrayList) listOfSomething; + assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomething)); + assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(List){} // Should match + list = listOfSomething; + assertTrue(ajList.isAssignableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check + arraylist = (ArrayList) listOfSomething; + assertFalse(ajArrayList.isAssignableFrom(ajListOfSomething)); + assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(List){}//: Should match + list = listOfSomething; + assertTrue(ajList.isAssignableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check + arrayListOfSomething = (ArrayList) listOfSomething; + assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomething)); + assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomething)); + + // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning + arrayListOfString = (ArrayList) listOfSomething; + assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomething)); + assertTrue(ajArrayListOfString.isCoerceableFrom(ajListOfSomething)); } + // public void testAssignable_method_m5() { + // List list = new ArrayList(); + // ArrayList arraylist = null; + // List listOfString = new ArrayList(); + // List listOfSomething = new ArrayList(); + // ArrayList arrayListOfSomething = null; + // List listOfNumber = null; + // ArrayList arrayListOfNumber = null; + // ArrayList arrayListOfSomethingNumberish = null; + // List listOfSomethingNumberish = new ArrayList(); + // List listOfSomethingSuperDouble = new ArrayList(); + // List listOfInteger = new ArrayList(); + // ArrayList arrayListOfString; + // ArrayList arraylistOfInteger; + // // interfaces too List + // + // ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); + // ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList;"); + // ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList;"); + // ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;"); + // ReferenceType ajList = resolve("Ljava/util/List;"); + // ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;"); + // ReferenceType ajListOfString = resolve("Pjava/util/List;"); + // ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); + // ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;"); + // ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); + // ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); + // ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); + // ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); + // ReferenceType ajListOfEextendsNumber = resolve("Pjava/util/List<+TE") + // + // // class C { + // // void m5(List e) { } + // // + // // void around(): execution(* C.m5(..)) && args(List){} Should not match (but it does) ERROR + // + // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should not match (but it does!) ERROR + // // void around(): execution(* C.m5(..)) && args(List){}//: Should not match (but it does!) ERROR + // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should not match (it does) ERROR + // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) + // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) + // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) + // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR + // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) + // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does not match!) + // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should not match (it does not match!) + // // + // // // void around(): execution(* D2.m5(..)) && args(List){} //: Should + // // not match (but it does) ERROR + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: + // // Should not match (but it does!) ERROR + // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should + // // not match (but it does!) ERROR + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: + // // Should not match (it does) ERROR + // // // void around(): execution(* D2.m5(..)) && args(List){}//: + // // Should match (it does) + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) + // // // void around(): execution(* D2.m5(..)) && args(List){}//: + // // Should match (it does) + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) + // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should match + // // (it does) + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should + // // runtime check (it does not match!) ERROR + // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should + // // match (it does) + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: + // // Should runtime check (it does not match!) + // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: + // // Should not match (it does not match!) + // // + // // // void around(): execution(* C.m6(..)) && args(List){} //: + // // Should not match (but it does) ERROR + // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: + // // Should not match (but it does!) ERROR + // // // void around(): execution(* C.m6(..)) && args(List){}//: Should + // // not match (but it does!) ERROR + // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: + // // Should not match (it does) ERROR + // // // void around(): execution(* C.m6(..)) && args(List){}//: Should match (it does) + // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should runtime check (it does!) + // // // void around(): execution(* C.m6(..)) && args(List){}//: Should match + // // (it does) + // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should + // // runtime check (it does not match!) + // // // void around(): execution(* C.m6(..)) && args(List){}//: Should + // // match (it does) + // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should + // // runtime check (it does not match!) + // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: + // // Should not match (it does not match!) + // // + // // // void around(): execution(* C.m7(..)) && args(List>){} + // // //: Should not match (but it does) ERROR + // // // void around(): execution(* C.m7(..)) && + // // args(ArrayList>){}//: Should not match (but it does!) ERROR + // // // void around(): execution(* C.m7(..)) && args(List>){}//: + // // Should not match (but it does!) ERROR + // // // void around(): execution(* C.m7(..)) && + // // args(ArrayList>){}//: Should not match (but it does) ERROR + // // // void around(): execution(* C.m7(..)) && args(List>){}//: Should not match (but it does) ERROR + // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends + // // List>){}//: Should not match (but it does!) ERROR + // // // void around(): execution(* C.m7(..)) && args(List< ? extends List>){}//: Should match (it does!) + // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends + // // List>){}//: Should match (it does!) + // // // void around(): execution(* C.m7(..)) && args(List){}//: Should match + // // (it does) + // // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should + // // runtime check (it does not match!) + // // // void around(): execution(* C.m7(..)) && args(List){}//: Should + // // match (it does) + // // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should + // // runtime check (it does!) + // // // void around(): execution(* C.m7(..)) && + // // args(ArrayList>){}//: Should not match (it does not match!) + // // + // // // void around(): execution(* C.m8(..)) && args(List){} //: + // // Should match with unchecked conversion (it does) + // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: + // // Should runtime check with unchecked conversion (it does!) + // // // void around(): execution(* C.m8(..)) && args(List){}//: Should + // // match with unchecked conversion (it does!) + // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: + // // Should runtime check with unchecked conversion (it does) + // // // void around(): execution(* C.m8(..)) && args(List){}//: Should match with unchecked conversion (it does!) + // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should runtime check with unchecked conversion (it does) + // // // void around(): execution(* C.m8(..)) && args(List){}//: Should match + // // (it does) + // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should + // // runtime check (it does!) + // // // void around(): execution(* C.m8(..)) && args(List){}//: Should + // // match (it does) + // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should + // // runtime check (it does!) + // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: + // // Should not match (it does not match!) + // // + // // // void around(): execution(* C.m9(..)) && args(List){} //: + // // Should not match (but it does) ERROR + // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: + // // Should not match (it does not match!) + // // // void around(): execution(* C.m9(..)) && args(Number){}//: Should match + // // (it does!) + // // // void around(): execution(* C.m9(..)) && args(Integer){}//: Should + // // runtime check (it does) + // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not match (but it does) ERROR + // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should not match (it does not match!) + // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not + // // match (but it does) ERROR + // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should + // // not match (it does not match!) + // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not + // // match (but it does) ERROR + // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should + // // not match (it does not match!) + // // // void around(): execution(* C.m9(..)) && args(String){}//: Should not + // // match (it does not match!) + // + // } + private ReferenceType resolve(String sig) { return (ReferenceType) world.resolve(UnresolvedType.forSignature(sig)); } -- 2.39.5