diff options
Diffstat (limited to 'tests/new/NotThis.java')
-rw-r--r-- | tests/new/NotThis.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/new/NotThis.java b/tests/new/NotThis.java new file mode 100644 index 000000000..413bcbd94 --- /dev/null +++ b/tests/new/NotThis.java @@ -0,0 +1,61 @@ +import org.aspectj.testing.Tester; + +/** From PR #496 from Mark Skipper + */ + +public class NotThis { + + public static void main(String[] args){ + new NotThis().go(); + } + + void go(){ + A a = new A(this); + a.go(); + Tester.checkEqual(Q.buf.toString(), "foo:within(A):this(A):!within(B):!this(B):"); + Q.buf = new StringBuffer(); + B b = new B(this); + b.go(); + Tester.checkEqual(Q.buf.toString(), "foo:"); + } + + public void foo(Object o){ + Q.buf.append("foo:"); + } +} + +class A { + NotThis t; + + A(NotThis n){ t = n; } + + void go(){ t.foo(this); } +} + + +class B{ + + NotThis t; + + B(NotThis n){ t = n; } + + void go(){ t.foo(this); } + +} + + +aspect Q { + static StringBuffer buf = new StringBuffer(); + after(): call(void NotThis.foo(Object)) && within(A) { + buf.append("within(A):"); + } + after(): call(void NotThis.foo(Object)) && this(A) { + buf.append("this(A):"); + } + after(): call(void NotThis.foo(Object)) && !within(B) { + buf.append("!within(B):"); + } + after(): call(void NotThis.foo(Object)) && !this(B) { + buf.append("!this(B):"); + } +} |