You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ArgsInCflow.java 875B

1234567891011121314151617181920212223242526272829303132333435
  1. import org.aspectj.testing.*;
  2. /** PR#659 name binding in around cflow containing cflowbelow */
  3. public class ArgsInCflow {
  4. public static void main(String[] args) {
  5. Tester.check(6==fact(3), "6==fact(3)");
  6. Tester.checkAllEvents();
  7. }
  8. static int fact(int x) {
  9. if (x<0) x = -x;
  10. if (x==0) return 1;
  11. else return x*fact(x-1);
  12. }
  13. static {
  14. Tester.expectEvent("3-2");
  15. Tester.expectEvent("3-1");
  16. Tester.expectEvent("3-0");
  17. }
  18. }
  19. aspect Test {
  20. // picks any calls to fact.
  21. pointcut factCall(int n) : call(int fact(int)) && args(n);
  22. // picks parameter to the first and current fact calls
  23. before(int n, int firstN, int dummy) :
  24. factCall(n)
  25. && cflow(factCall(firstN)
  26. && !cflowbelow(factCall(dummy))) {
  27. Tester.event(firstN + "-" + n);
  28. }
  29. }