summaryrefslogtreecommitdiffstats
path: root/tests/new
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-01-13 11:27:59 +0000
committeracolyer <acolyer>2004-01-13 11:27:59 +0000
commit19ed0a21b822004f6f2c688518c4230965a3b512 (patch)
tree5680a8ccc55b3d2bbe634b38717d08dc6328f214 /tests/new
parent346fd1c4acfa5360e1a71aa171da283251ef99bf (diff)
downloadaspectj-19ed0a21b822004f6f2c688518c4230965a3b512.tar.gz
aspectj-19ed0a21b822004f6f2c688518c4230965a3b512.zip
move to Eclipse 3.0 M6 JDT core (v_396). Also makes 1.4 the
default mode (inherited behaviour from JDT).
Diffstat (limited to 'tests/new')
-rw-r--r--tests/new/AroundChangeThis.java18
-rw-r--r--tests/new/AroundInnerCalls.java6
-rw-r--r--tests/new/AroundInnerCalls13.java56
-rw-r--r--tests/new/DeclareMethodCE.java3
-rw-r--r--tests/new/InterfaceConstructor.java2
-rw-r--r--tests/new/RecognizeAspectCE.java6
-rw-r--r--tests/new/perThis/p/EachObjectTarget.java13
-rw-r--r--tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java11
8 files changed, 101 insertions, 14 deletions
diff --git a/tests/new/AroundChangeThis.java b/tests/new/AroundChangeThis.java
index bf96cdd9b..826e95b52 100644
--- a/tests/new/AroundChangeThis.java
+++ b/tests/new/AroundChangeThis.java
@@ -12,15 +12,23 @@ public class AroundChangeThis {
c1.m(sc);
Tester.checkAndClearEvents(new String[] { "c1.m(sc)", "sc.m(c1)" });
- sc.m(c1);
- Tester.checkAndClearEvents(new String[] { "sc.m(c1)", "c1.m(sc)" });
-
+// this is the 1.3 behaviour
+// sc.m(c1);
+// Tester.checkAndClearEvents(new String[] { "sc.m(c1)", "c1.m(sc)" });
+
+ try {
+ // the 1.4 behaviour is....
+ // in byte code we have a call to SubC.m
+ sc.m(c1);
+ Tester.checkFailed("Expected ClassCastException");
+ } catch (ClassCastException e) {
+ }
+
try {
sc.m1(c1);
+ Tester.checkFailed("Expected ClassCastException");
} catch (ClassCastException e) {
- Tester.event("ClassCastException");
}
- Tester.checkAndClearEvents(new String[] { "ClassCastException" });
Tester.printEvents();
}
diff --git a/tests/new/AroundInnerCalls.java b/tests/new/AroundInnerCalls.java
index 6cdd966a1..64a55caf8 100644
--- a/tests/new/AroundInnerCalls.java
+++ b/tests/new/AroundInnerCalls.java
@@ -6,11 +6,11 @@ public class AroundInnerCalls {
Tester.check("Outer.foo() calls Outer.Inner.mi()");
Tester.check("Outer.foo() calls Outer.InnerRandom.nextHook(..)");
- Tester.check("Outer.InnerRandom.nextHook(..) calls Random.next(..)");
+ Tester.check("Outer.InnerRandom.nextHook(..) calls Outer.InnerRandom.next(..)");
Tester.check("Outer.Inner.mi() calls PrintStream.println(..)");
Tester.check("X.toString()");
- Tester.check("Outer.foo() calls Random.nextInt(..)");
+ Tester.check("Outer.foo() calls Outer.1.nextInt(..)");
}
}
@@ -37,7 +37,7 @@ class Outer {
aspect A {
Object around(): call(* *(..)) && !within(A) {
- //System.out.println
+// System.out.println
Tester.note
(thisEnclosingJoinPointStaticPart.getSignature().toShortString() +
" calls " + thisJoinPointStaticPart.getSignature().toShortString());
diff --git a/tests/new/AroundInnerCalls13.java b/tests/new/AroundInnerCalls13.java
new file mode 100644
index 000000000..0903eae27
--- /dev/null
+++ b/tests/new/AroundInnerCalls13.java
@@ -0,0 +1,56 @@
+import org.aspectj.testing.Tester;
+
+public class AroundInnerCalls13 {
+ public static void main(String[] args) {
+ new Outer().foo();
+
+ Tester.check("Outer.foo() calls Outer.Inner.mi()");
+ Tester.check("Outer.foo() calls Outer.InnerRandom.nextHook(..)");
+ Tester.check("Outer.InnerRandom.nextHook(..) calls Random.next(..)");
+ Tester.check("Outer.Inner.mi() calls PrintStream.println(..)");
+
+ Tester.check("X.toString()");
+ Tester.check("Outer.foo() calls Random.nextInt(..)");
+ }
+}
+
+class Outer {
+ private class Inner extends Object {
+ public void mi() {
+ System.out.println(".");
+ }
+ }
+
+ public void foo() {
+ new Inner().mi();
+ new InnerRandom().nextHook(2);
+
+ new java.util.Random() { public String toString() { Tester.note("X.toString()"); return "X"; } }.nextInt(2);
+ }
+
+ private class InnerRandom extends java.util.Random {
+ public int nextHook(int bits) {
+ return next(bits);
+ }
+ }
+}
+
+aspect A {
+ Object around(): call(* *(..)) && !within(A) {
+// System.out.println
+ Tester.note
+ (thisEnclosingJoinPointStaticPart.getSignature().toShortString() +
+ " calls " + thisJoinPointStaticPart.getSignature().toShortString());
+ return proceed();
+ }
+
+ before(Object caller, Object callee):
+ this(caller) && target(callee) && call(* *(..)) && !within(A)
+ {
+ System.out.println(thisEnclosingJoinPointStaticPart.getSignature().toShortString() +
+ " calls " + thisJoinPointStaticPart.getSignature().toShortString());
+ System.out.println
+ (caller + "." + thisEnclosingJoinPointStaticPart.getSignature().getName() +
+ " calls " + callee + "." + thisJoinPoint.getSignature().getName());
+ }
+}
diff --git a/tests/new/DeclareMethodCE.java b/tests/new/DeclareMethodCE.java
index ded55022f..bad23e569 100644
--- a/tests/new/DeclareMethodCE.java
+++ b/tests/new/DeclareMethodCE.java
@@ -5,7 +5,6 @@ class B {}
aspect A {
void B.n() {
- void n() { // CE 8 method declared in method
- }
+ void n() { } // CE 8 method declared in method
}
}
diff --git a/tests/new/InterfaceConstructor.java b/tests/new/InterfaceConstructor.java
index 080e4406b..49a6ded3c 100644
--- a/tests/new/InterfaceConstructor.java
+++ b/tests/new/InterfaceConstructor.java
@@ -3,7 +3,7 @@ interface i {
}
class c {
- c(); //ERR: constructors must have bodies
+ c(); //ERR: constructors must have bodies
abstract c(int i) { } //ERR: constructors can't be abstract
}
diff --git a/tests/new/RecognizeAspectCE.java b/tests/new/RecognizeAspectCE.java
index a84effb04..92fb6df1c 100644
--- a/tests/new/RecognizeAspectCE.java
+++ b/tests/new/RecognizeAspectCE.java
@@ -1,7 +1,7 @@
// PR#457
class RecognizeAspectCE {
public static void main(String[] ignore) { }
- pointcut mumble() // would like error here: "pointcuts not allowed in classes - use aspect"
- : execution(public static void RecognizeAspectCE.main(String[]));
- before(): mumble() { } // ok: get error here: constructor has the wrong name
+// pointcut mumble()
+// : execution(public static void RecognizeAspectCE.main(String[]));
+ before(): this(*) { } // ok: get error here: constructor has the wrong name
}
diff --git a/tests/new/perThis/p/EachObjectTarget.java b/tests/new/perThis/p/EachObjectTarget.java
new file mode 100644
index 000000000..bf9c364af
--- /dev/null
+++ b/tests/new/perThis/p/EachObjectTarget.java
@@ -0,0 +1,13 @@
+package p;
+import org.aspectj.testing.Tester;
+
+public class EachObjectTarget {
+ public static void main(String[] args) {
+ EachObjectTarget o = new EachObjectTarget();
+ o.foo();
+ }
+
+ void foo() {
+ Tester.check(true, "Dummy test");
+ }
+}
diff --git a/tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java b/tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java
new file mode 100644
index 000000000..8b862e451
--- /dev/null
+++ b/tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java
@@ -0,0 +1,11 @@
+package the.deep.pkg;
+
+import org.aspectj.testing.Tester;
+import p.EachObjectTarget;
+
+aspect Aspect pertarget(target(EachObjectTarget)) {
+ before(): call(void foo(..)) {
+ EachObjectTarget t = null;
+ Tester.check(true, "Dummy test");
+ }
+}