diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/design/intro/Simple.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/design/intro/Simple.java')
-rw-r--r-- | tests/design/intro/Simple.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/design/intro/Simple.java b/tests/design/intro/Simple.java new file mode 100644 index 000000000..cd995d993 --- /dev/null +++ b/tests/design/intro/Simple.java @@ -0,0 +1,80 @@ +import org.aspectj.testing.Tester; + +public class Simple { + public static void main(String[] args) { + C c = new C(); + I i = (I)new C("hi"); + Tester.checkEqual(c.foo(), "foo:bar"); + Tester.checkEqual(i.mumble(), "mumble:foo:bar"); + + Tester.checkEqual(A.Cm(), "from A"); + Tester.checkEqual(B.Cm(), "from B"); + + c.idata = "c-mumble"; + Tester.checkEqual(c.idata, "c-mumble"); + Tester.checkEqual(i.idata, "mumble"); + + Tester.check("new A.C"); + Tester.check("new B.C"); + } +} + +class C { + public C() { super(); } + public String bar() {return "bar"; } +} + +interface I { + String foo(); + String bar(); +} + + +aspect A { + private String C.data = "foo"; + private String C.data1 = this.data; + + public String I.idata = "mumble"; + + public String C.foo() { + String s = this.data; + Tester.checkEqual(s, data1); + return data + ":" + bar(); + } + + declare parents: C implements I; + + public String I.mumble() { + return idata + ":" + foo(); + } + + private String C.m() { + return "from A"; + } + + public static String Cm() { + return new C(2).m(); + } + + public C.new(String s) { } + + private C.new(int i) { + Tester.note("new A.C"); + } +} + +aspect B { + private String C.data = "B"; + + private String C.m() { + return "from " + data; + } + + public static String Cm() { + return new C(2).m(); + } + + private C.new(int i) { + Tester.note("new B.C"); + } +} |