]> source.dussan.org Git - aspectj.git/commitdiff
more ambiguous bindings testing
authoracolyer <acolyer>
Thu, 16 Dec 2004 13:08:07 +0000 (13:08 +0000)
committeracolyer <acolyer>
Thu, 16 Dec 2004 13:08:07 +0000 (13:08 +0000)
tests/bugs/AmbiguousBindings.aj [new file with mode: 0644]
tests/bugs/PR61658.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml

diff --git a/tests/bugs/AmbiguousBindings.aj b/tests/bugs/AmbiguousBindings.aj
new file mode 100644 (file)
index 0000000..ade1f31
--- /dev/null
@@ -0,0 +1,60 @@
+// pushes the limits of what ajc will accept as an unambiguous binding...\r
+\r
+aspect AmbiguousBindings {\r
+       \r
+       pointcut p1(Foo foo) : (call(* *(..)) && this(foo)) || (execution(* *(..)) && args(foo)); \r
+       \r
+       pointcut p2(Foo foo) : (call(* m(..)) && this(foo)) || (call(* n(..)) && args(foo));\r
+       \r
+       pointcut p3(Foo foo) : (execution(* *(int,int)) && this(foo)) || (execution(* *(int)) && this(foo));\r
+       \r
+       pointcut p4(Foo foo) : (get(int a) && this(foo)) || (get(int b) && target(foo));\r
+       \r
+       pointcut p5(int x) : (set(int a) && args(x)) || (set(int b) && args(x));\r
+       \r
+       pointcut p6(Foo foo) : (within(Foo) && this(foo)) || (within(AmbiguousBindings) && args(foo));\r
+\r
+       pointcut q1(Foo foo) : (call(* m(..)) && this(foo)) || (call(* m*(..)) && args(foo));\r
+       \r
+       pointcut q2(Foo foo) : (execution(* *(int,int)) && this(foo)) || (execution(* *(int,*)) && args(foo));\r
+       \r
+       pointcut q3(Foo foo) : (get(int a) && this(foo)) || (get(int a) && target(foo));\r
+       \r
+       pointcut q4(int x) : (set(int a) && args(x)) || (set(* *) && this(x));\r
+       \r
+       pointcut q5(Foo foo) : (within(Foo) && this(foo)) || (within(F*) && args(foo));\r
+\r
+       // these should be good\r
+       before(Foo foo) : p1(foo) {}\r
+       before(Foo foo) : p2(foo) {}\r
+       before(Foo foo) : p3(foo) {}\r
+       before(Foo foo) : p4(foo) {}\r
+       before(int z) : p5(z) {}\r
+       before(Foo foo) : p6(foo) {}\r
+       \r
+       // these are all ambiguous\r
+       before(Foo foo) : q1(foo) {}\r
+       before(Foo foo) : q2(foo) {}\r
+       before(Foo foo) : q3(foo) {}\r
+       before(int x) : q4(x) {}\r
+       before(Foo foo) : q5(foo) {}\r
+       \r
+}\r
+\r
+\r
+class Foo {\r
+       \r
+       int a;\r
+       int b;\r
+       \r
+       public void m(int x, int y) {\r
+               a = y;\r
+               n(x);\r
+       }\r
+       \r
+       public void n(int x) {\r
+               b = x;\r
+               a = a * 2;\r
+       }\r
+       \r
+}
\ No newline at end of file
diff --git a/tests/bugs/PR61658.java b/tests/bugs/PR61658.java
new file mode 100644 (file)
index 0000000..1949ed6
--- /dev/null
@@ -0,0 +1,37 @@
+class A {
+       void m() {
+           System.out.println("A");
+       }
+ }
+
+class B extends A {
+        void m() {
+           System.out.println("B");
+    }
+ }
+
+
+aspect FunkyPointcut { 
+
+    after(A a, B b) returning:
+       call(* foo(*,*)) && 
+       (args(b,a) || args(a,b)) { 
+        System.out.println("Woven"); 
+    } 
+}
+
+
+public class PR61658 { 
+
+    public static void foo(A a, A b) {
+       a.m();
+        b.m();
+    }
+
+    public static void main(String[] args) {
+        A a = new A();
+        B b = new B(); 
+        foo(b,a); 
+    } 
+}
\ No newline at end of file
index 25d4e8f809829ae50cf068550052f00d451fed67..fdd6f10a42366ad9a037120260cdeff05ffd3345 100644 (file)
@@ -33,4 +33,12 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                System.err.println(ajc.getLastCompilationResult().getStandardError());
        }
   }
+  
+  public void test_ambiguousBindingsDetection() {
+       runTest("Various kinds of ambiguous bindings");
+  }
+  
+  public void test_ambiguousArgsDetection() {
+       runTest("ambiguous args");
+  }
 }
\ No newline at end of file
index f2023d6c9b9d8c9549dabf7dc7874ea1ce349150..c0fbc6bd2f804b49b99ee4d4d90b0abe8439dbef 100644 (file)
         <run class="B"/>
         <compile files="B.java,A.java,AspectX.java"/>
         <run class="B"/>
+    </ajc-test>
+    
+    <ajc-test dir="bugs" pr="61568" title="Various kinds of ambiguous bindings">
+        <compile files="AmbiguousBindings.aj">
+            <message line="17" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message>
+            <message line="19" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message>
+            <message line="21" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message>
+            <message line="23" text="ambiguous binding of parameter(s) x across '||' in pointcut"></message>
+            <message line="25" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message>
+        </compile>
+    </ajc-test>
+    
+    <ajc-test dir="bugs" pr="61658" title="ambiguous args">
+        <compile files="PR61658.java">
+            <message line="17" text="ambiguous binding of parameter(s) a, b across '||' in pointcut"></message>
+        </compile>
     </ajc-test>
\ No newline at end of file