From 9380b983d27b392777788c754cfdc27691d52032 Mon Sep 17 00:00:00 2001 From: acolyer Date: Fri, 10 Dec 2004 11:26:37 +0000 Subject: [PATCH] testing for @args --- .../java5/annotations/args/AtArgsAspect.java | 125 ++++++++++++++++++ .../args/TestingArgsAnnotations.jar | Bin 0 -> 4228 bytes .../args/TestingArgsAnnotations.java | 84 ++++++++++++ .../ajc150/AnnotationRuntimeTests.java | 8 +- 4 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 tests/java5/annotations/args/AtArgsAspect.java create mode 100644 tests/java5/annotations/args/TestingArgsAnnotations.jar create mode 100644 tests/java5/annotations/args/TestingArgsAnnotations.java diff --git a/tests/java5/annotations/args/AtArgsAspect.java b/tests/java5/annotations/args/AtArgsAspect.java new file mode 100644 index 000000000..5a5c8a4f7 --- /dev/null +++ b/tests/java5/annotations/args/AtArgsAspect.java @@ -0,0 +1,125 @@ +public aspect AtArgsAspect { + + + pointcut myMethod() : execution(* myMethod(..)); + + // Exact number of args + // test 0 + before() : myMethod() && @args(*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // One too few + // test 1 + before() : myMethod() && @args(*,*,*,*) { + System.out.print("@args(*,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,*) { + System.out.print("@args(*,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // One too many + // test 2 + before() : myMethod() && @args(*,*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,*,*,*) { + System.out.print("@args(*,*,*,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Exact number of args + ellipsis + // test 3 + before() : myMethod() && @args(*,*,..,*,*,*) { + System.out.print("@args(*,*,..,*,*,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,..,*,*,*) { + System.out.print("@args(*,*,..,*,*,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Too few + ellipsis + // test 4 + before() : myMethod() && @args(*,*,*,..) { + System.out.print("@args(*,*,*,..): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(*,*,*,..) { + System.out.print("@args(*,*,*,..): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Now we get to test some annotations! + + // Non-inherited + // test 5 + before() : myMethod() && @args(@MyAnnotation,..) { + System.out.print("@args(@MyAnnotation,..): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(@MyAnnotation,..) { + System.out.print("@args(@MyAnnotation,..): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 6 + before() : myMethod() && @args(@MyAnnotation,*,*,@MyAnnotation,*) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(@MyAnnotation,*,*,@MyAnnotation,*) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 7 + before() : myMethod() && @args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation) { + System.out.print("@args(@MyAnnotation,*,*,@MyAnnotation,@MyAnnotation): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // Inherited + // test 8 + before() : myMethod() && @args(..,@MyInheritableAnnotation,*) { + System.out.print("@args(..,@MyInheritableAnnotation,*): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(..,@MyInheritableAnnotation,*) { + System.out.print("@args(..,@MyInheritableAnnotation,*): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 9 + before() : myMethod() && @args(..,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + + // test 10 + before() : myMethod() && @args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + before() : myMethod() && !@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation) { + System.out.print("@args(..,@MyInheritableAnnotation,@MyInheritableAnnotation,@MyInheritableAnnotation): "); + System.out.println(!TestingArgsAnnotations.expected() ? "PASS" : "FAIL"); + } + +} \ No newline at end of file diff --git a/tests/java5/annotations/args/TestingArgsAnnotations.jar b/tests/java5/annotations/args/TestingArgsAnnotations.jar new file mode 100644 index 0000000000000000000000000000000000000000..8068f1f459a7e0a1868111afcad22920d1744a46 GIT binary patch literal 4228 zcma)92UJtp77Z;FDWRjGh9*SYWJz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