blob: 2ee5c7e3a26d77eafc6e62cd7f945d404368c5f5 (
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.*;
/** PR#659 name binding in around cflow containing cflowbelow */
public class ArgsInCflow {
public static void main(String[] args) {
Tester.check(6==fact(3), "6==fact(3)");
Tester.checkAllEvents();
}
static int fact(int x) {
if (x<0) x = -x;
if (x==0) return 1;
else return x*fact(x-1);
}
static {
Tester.expectEvent("3-2");
Tester.expectEvent("3-1");
Tester.expectEvent("3-0");
}
}
aspect Test {
// picks any calls to fact.
pointcut factCall(int n) : call(int fact(int)) && args(n);
// picks parameter to the first and current fact calls
before(int n, int firstN, int dummy) :
factCall(n)
&& cflow(factCall(firstN)
&& !cflowbelow(factCall(dummy))) {
Tester.event(firstN + "-" + n);
}
}
|