summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-12-16 13:08:07 +0000
committeracolyer <acolyer>2004-12-16 13:08:07 +0000
commitd2ef5057552185144c54afa37a7f7de81664ea9c (patch)
treea6c03f61b6b98a1ffb23d855bc89dada210e73c9
parent2f85beef220b0b67fefb587b9045d80fd1356da1 (diff)
downloadaspectj-d2ef5057552185144c54afa37a7f7de81664ea9c.tar.gz
aspectj-d2ef5057552185144c54afa37a7f7de81664ea9c.zip
more ambiguous bindings testing
-rw-r--r--tests/bugs/AmbiguousBindings.aj60
-rw-r--r--tests/bugs/PR61658.java37
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java8
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml16
4 files changed, 121 insertions, 0 deletions
diff --git a/tests/bugs/AmbiguousBindings.aj b/tests/bugs/AmbiguousBindings.aj
new file mode 100644
index 000000000..ade1f3113
--- /dev/null
+++ b/tests/bugs/AmbiguousBindings.aj
@@ -0,0 +1,60 @@
+// pushes the limits of what ajc will accept as an unambiguous binding...
+
+aspect AmbiguousBindings {
+
+ pointcut p1(Foo foo) : (call(* *(..)) && this(foo)) || (execution(* *(..)) && args(foo));
+
+ pointcut p2(Foo foo) : (call(* m(..)) && this(foo)) || (call(* n(..)) && args(foo));
+
+ pointcut p3(Foo foo) : (execution(* *(int,int)) && this(foo)) || (execution(* *(int)) && this(foo));
+
+ pointcut p4(Foo foo) : (get(int a) && this(foo)) || (get(int b) && target(foo));
+
+ pointcut p5(int x) : (set(int a) && args(x)) || (set(int b) && args(x));
+
+ pointcut p6(Foo foo) : (within(Foo) && this(foo)) || (within(AmbiguousBindings) && args(foo));
+
+ pointcut q1(Foo foo) : (call(* m(..)) && this(foo)) || (call(* m*(..)) && args(foo));
+
+ pointcut q2(Foo foo) : (execution(* *(int,int)) && this(foo)) || (execution(* *(int,*)) && args(foo));
+
+ pointcut q3(Foo foo) : (get(int a) && this(foo)) || (get(int a) && target(foo));
+
+ pointcut q4(int x) : (set(int a) && args(x)) || (set(* *) && this(x));
+
+ pointcut q5(Foo foo) : (within(Foo) && this(foo)) || (within(F*) && args(foo));
+
+ // these should be good
+ before(Foo foo) : p1(foo) {}
+ before(Foo foo) : p2(foo) {}
+ before(Foo foo) : p3(foo) {}
+ before(Foo foo) : p4(foo) {}
+ before(int z) : p5(z) {}
+ before(Foo foo) : p6(foo) {}
+
+ // these are all ambiguous
+ before(Foo foo) : q1(foo) {}
+ before(Foo foo) : q2(foo) {}
+ before(Foo foo) : q3(foo) {}
+ before(int x) : q4(x) {}
+ before(Foo foo) : q5(foo) {}
+
+}
+
+
+class Foo {
+
+ int a;
+ int b;
+
+ public void m(int x, int y) {
+ a = y;
+ n(x);
+ }
+
+ public void n(int x) {
+ b = x;
+ a = a * 2;
+ }
+
+} \ No newline at end of file
diff --git a/tests/bugs/PR61658.java b/tests/bugs/PR61658.java
new file mode 100644
index 000000000..1949ed6dc
--- /dev/null
+++ b/tests/bugs/PR61658.java
@@ -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
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index 25d4e8f80..fdd6f10a4 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -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
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml
index f2023d6c9..c0fbc6bd2 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150-tests.xml
@@ -12,4 +12,20 @@
<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