From 144143c2970a1e874d74cdbd0f8c622d4282a3c3 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 16 Dec 2002 18:51:06 +0000 Subject: initial version --- tests/new/PR335.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/new/PR335.java (limited to 'tests/new/PR335.java') diff --git a/tests/new/PR335.java b/tests/new/PR335.java new file mode 100644 index 000000000..8fc4db660 --- /dev/null +++ b/tests/new/PR335.java @@ -0,0 +1,50 @@ +import org.aspectj.testing.*; + +public class PR335 { + public static void main(String[] args) { + Ship s = new Ship(); + Tester.clearEvents(); + s.handleCollision(); + Tester.checkAndClearEvents("before3(d=0) inflictDamage(0) handleCollision()"); + s.handleCollision("dummy"); + Tester.checkAndClearEvents("before1(so=dummy,d=1) inflictDamage(1) handleCollision(Object)"); + s.handleCollision(1); + Tester.checkAndClearEvents("before2(so=1,d=2) inflictDamage(2) handleCollision(int)"); + s.inflictDamage(3); + Tester.checkAndClearEvents("inflictDamage(3)"); + } +} + + +aspect Bug1 { + pointcut collisionDamage(Ship s, Object so, int d) : + this(s) + && cflow(call(void handleCollision(Object)) && args(so)) + && call(void Ship.inflictDamage(int)) && args(d); + before(Ship s, Object so, int d) : collisionDamage(s, so, d) { + Tester.event("before1(so="+so.toString()+",d="+d+")"); + } + + pointcut collisionDamage2(Ship s, int so, int d) : + this(s) + && cflow(call(void handleCollision(int)) && args(so)) + && call(void Ship.inflictDamage(int)) && args(d); + before(Ship s, Object so, int d) : collisionDamage2(s, so, d) { + Tester.event("before2(so="+so+",d="+d+")"); + } + + pointcut collisionDamage3(Ship s, int d) : + this(s) + && withincode(void handleCollision()) + && call(void Ship.inflictDamage(int)) && args(d); + before(Ship s, int d) : collisionDamage3(s, d) { + Tester.event("before3(d="+d+")"); + } +} + +class Ship { + void handleCollision() { inflictDamage(0); Tester.event("handleCollision()"); } + void handleCollision(Object so) { inflictDamage(1); Tester.event("handleCollision(Object)"); } + void handleCollision(int so) { inflictDamage(2); Tester.event("handleCollision(int)"); } + void inflictDamage(int i) { Tester.event("inflictDamage(" + i + ")"); } +} -- cgit v1.2.3