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/new/CFlowPoints.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/CFlowPoints.java')
-rw-r--r-- | tests/new/CFlowPoints.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/new/CFlowPoints.java b/tests/new/CFlowPoints.java new file mode 100644 index 000000000..f81660a39 --- /dev/null +++ b/tests/new/CFlowPoints.java @@ -0,0 +1,62 @@ +import org.aspectj.testing.Tester; + +public class CFlowPoints { + public static void main(String[] args){ + new Test().go(2); + Tester.checkEqual(Test.callsPerCFlow, 2+1, "3 call for each cflow"); + + Test.callsPerCFlow = 0; + + new Test().go(3); + Tester.checkEqual(Test.callsPerCFlow, 3+2+1, "6 call for each cflow"); + + try { + Each.aspectOf(); + Tester.checkFailed("should have thrown exception"); + } catch (org.aspectj.lang.NoAspectBoundException exc) { + // this is what we want + } + } +} + +class Test { + static int cflowObjects = 0; + static int callsPerCFlow = 0; + + Object lastEachCFlow = null; + + void go(int n) { + for (int i=0; i<n; i++) foo("i", "i"); + + if (n >= 0) go(n-1); + + Tester.check(Each.aspectOf() != lastEachCFlow, "unique eachcflows"); + + lastEachCFlow = Each.aspectOf(); + } + + void foo(String s1, String s2){} +} + +aspect A { + pointcut root(int x): target(Test) && call(void go(int)) && args(x); + + pointcut flow(int x): cflow(root(x)); + + before(): root(int) && !cflow(root(int)) { + Tester.checkEqual(Test.callsPerCFlow, 0, "top call"); + } + + before(String s1, int y, String s2): + flow(y) && target(Test) && target(Object) + && call(void *(String,String)) + && args(s1,s2) + { + Test.callsPerCFlow++; + Tester.checkEqual(s1, s2, "extra parameters"); + } +} + +aspect Each percflow(flowCut()) { + pointcut flowCut(): target(Test) && call(void go(int)); +} |