aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/CFlowObjects.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/new/CFlowObjects.java')
-rw-r--r--tests/new/CFlowObjects.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/new/CFlowObjects.java b/tests/new/CFlowObjects.java
new file mode 100644
index 000000000..598cab2c3
--- /dev/null
+++ b/tests/new/CFlowObjects.java
@@ -0,0 +1,35 @@
+import org.aspectj.testing.Tester;
+
+public class CFlowObjects {
+ public static void main(String[] args){
+ new Test().go();
+ Tester.checkEqual(Test.cflowObjects, 1, "1st cflow");
+ Tester.checkEqual(Test.callsPerCFlow, 1, "1 call for each cflow");
+
+ new Test().go();
+ Tester.checkEqual(Test.cflowObjects, 2, "2nd cflow");
+ Tester.checkEqual(Test.callsPerCFlow, 1, "1 call for each cflow");
+ }
+}
+
+class Test {
+ static int cflowObjects = 0;
+ static int callsPerCFlow = 0;
+
+ void go(){
+ foo();
+ }
+
+ void foo(){}
+}
+
+aspect A percflow(target(Test) && call(void go())) {
+
+ { Test.cflowObjects++; }
+ { Test.callsPerCFlow = 0; }
+
+ //before(): instanceof(Test) && calls(void Object.*()){ Test.callsPerCFlow++; }
+ before(): within(Test) && call(void Object+.*(..)) {
+ Test.callsPerCFlow++;
+ }
+}