summaryrefslogtreecommitdiffstats
path: root/tests/base/test140
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/test140
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/base/test140')
-rw-r--r--tests/base/test140/Driver.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/base/test140/Driver.java b/tests/base/test140/Driver.java
new file mode 100644
index 000000000..db03998ae
--- /dev/null
+++ b/tests/base/test140/Driver.java
@@ -0,0 +1,68 @@
+import org.aspectj.testing.Tester;
+
+// aspect inheritance and advice, introduction
+
+public class Driver {
+ public static void test() {
+ C1 c1 = new C1();
+
+ Tester.checkEqual(c1.foo(), "from A2", "sub-aspects");
+ Tester.checkEqual(c1.bar(),
+ "from A0 #2",
+ "sub-aspects and position");
+
+ // the around advice lexically in A1 runs twice, once for each concrete
+ // sub-aspects. putting advice on a concrete pointcut in an abstract
+ // aspect will always have this odd behavior, and possibly should be illegal
+ Tester.checkEqual(c1.getString(),
+ ":A2:A1:A1:C1",
+ "multiple arounds");
+ }
+
+ public static void main(String[] args) { test(); }
+}
+
+class C1 {
+ String getString() {
+ return ":C1";
+ }
+}
+
+abstract aspect A1 {
+ String C1.foo() {
+ return "from A1";
+ }
+
+ String C1.bar() {
+ return "from A1";
+ }
+
+ String around():
+ call(String C1.getString()) {
+ return ":A1" + proceed();
+ }
+}
+
+aspect A2 extends A1 {
+ String C1.foo() {
+ return "from A2";
+ }
+
+ String around():
+ call(String C1.getString()) {
+ return ":A2" + proceed();
+ }
+
+}
+
+aspect A0 extends A1 {
+ // multiple conflicting declarations in the same aspect are now an error
+ //String C1.bar() {
+ // return "from A0 #1";
+ //}
+
+ String C1.bar() {
+ return "from A0 #2";
+ }
+}
+