aboutsummaryrefslogtreecommitdiffstats
path: root/tests/base/test136
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/base/test136
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/base/test136')
-rw-r--r--tests/base/test136/Driver.java119
1 files changed, 119 insertions, 0 deletions
diff --git a/tests/base/test136/Driver.java b/tests/base/test136/Driver.java
new file mode 100644
index 000000000..aca8e2dcc
--- /dev/null
+++ b/tests/base/test136/Driver.java
@@ -0,0 +1,119 @@
+import org.aspectj.testing.Tester;
+
+public class Driver {
+ public static void main(String[] args) { test(); }
+
+ public static void test() {
+ C0 c = new C2();
+ c.m1(2, 2);
+ Tester.checkEqual(A.C0_m1_calls, 1, "C2.m1 -- C0 calls");
+ Tester.checkEqual(A.C2_m1_calls, 1, "C2.m1 -- C2 calls");
+ Tester.checkEqual(A.m1_afters, 1, "C2.m1 -- after advice");
+ A.clearCounts();
+
+ c.m2(c);
+ Tester.checkEqual(A.C0_m1_calls, 1, "C2.m2 -- C0.m1 calls");
+ Tester.checkEqual(A.C2_m1_calls, 0, "C2.m2 -- C2.m1 calls");
+ Tester.checkEqual(A.m1_afters, 0, "C2.m2 -- after m1 advice");
+ Tester.checkEqual(A.C0_m2_calls, 1, "C2.m2 -- C0.m2 calls");
+ Tester.checkEqual(A.C2_m2_calls, 1, "C2.m2 -- C2.m2 calls");
+ Tester.checkEqual(A.m2_afters, 1, "C2.m2 -- after m2 advice");
+
+ c.m3("hi");
+ Tester.checkEqual(A.C0_m3_calls, 1, "C2.m3 -- C0 calls");
+ Tester.checkEqual(A.C1_m3_calls, 1, "C2.m3 -- C1 calls");
+ Tester.checkEqual(A.C2_m3_calls, 1, "C2.m3 -- C2 calls");
+ }
+}
+
+class C0 {
+ public C0() {
+ }
+
+ void m1(int x, double y) {
+ A.C0_m1_calls += 1;
+ }
+
+ void m2(C0 c0) {
+ A.C0_m2_calls += 1;
+ }
+ void m3(String s) {
+ A.C0_m3_calls += 1;
+ }
+
+}
+
+class C1 extends C0 {
+ void m3(String s) {
+ super.m3(s);
+ A.C1_m3_calls += 1;
+ }
+}
+
+class C2 extends C1 {
+ public boolean C2_after_called = false;
+
+ public void setC2_after_called( boolean newVal ) {
+ C2_after_called = newVal;
+ }
+
+ public C2() {
+ super();
+ }
+
+ void m1(int x, double y) {
+ A.C2_m1_calls += 1;
+ super.m1(x*2, x+y);
+ }
+
+ void m2(C0 c0) {
+ A.C2_m2_calls += 1;
+ super.m1(2, 2);
+ super.m2(this);
+ }
+ void m3(String s) {
+ super.m3(s);
+ A.C2_m3_calls += 1;
+ }
+}
+
+aspect A {
+ public static int C0_m1_calls = 0;
+ public static int C2_m1_calls = 0;
+ public static int C0_m2_calls = 0;
+ public static int C2_m2_calls = 0;
+ public static int C0_m3_calls = 0;
+ public static int C1_m3_calls = 0;
+ public static int C2_m3_calls = 0;
+ public static int m1_afters = 0;
+ public static int m2_afters = 0;
+
+ public static void clearCounts() {
+ C0_m1_calls = 0;
+ C2_m1_calls = 0;
+ C0_m2_calls = 0;
+ C2_m2_calls = 0;
+ C0_m3_calls = 0;
+ C1_m3_calls = 0;
+ C2_m3_calls = 0;
+ m1_afters = 0;
+ m2_afters = 0;
+ }
+
+ after(): target(C0+) && call(void m1(int, double)) {
+ m1_afters += 1;
+ }
+ after(): target(C0+) && call(* m2(..)) {
+ m2_afters += 1;
+ }
+
+ after(): target(C0+) && call(* m3(..)) {
+ int x = 22;
+ }
+
+ after(C2 c2) returning():
+ target(c2) && call(new()) {
+ c2.setC2_after_called( true );
+ }
+}
+