blob: 598cab2c38baf32baccbeafa7a1320cfe8014c3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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++;
}
}
|