summaryrefslogtreecommitdiffstats
path: root/tests/base/test125/Driver.java
blob: 171c2370be62c9ea197502ecfdc716ae15ed00a8 (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
36
37
38
39
40
41
42
43
44
45
import java.io.*;
import org.aspectj.testing.Tester;

public class Driver {
    public static void main(String[] args) { test(); }

    public static void test() {
        Point p = new Point();
        p.setX(3);
    }
}

class Point {
    int _x = 0;
    int _y = 0;

    Point() {}

    void set (int x, int y) {
        _x = x; _y = y;
    }

    void setX (int x) { _x = x; }
    void setY (int y) { _y = y; }

    int getX() { return _x; }
    int getY() { return _y; }
}

aspect Trace {
    static int oldvalue;

     before(Point p, int newvalue): target(p) && args(newvalue) &&
                                          (call(void setX(int)) ||
                                           call(void setY(int))) {
        oldvalue = p.getX();
    }
     after(Point p, int newvalue): target(p) && args(newvalue) &&
                                         (call(void setX(int)) ||
                                          call(void setY(int))) {
        
        Tester.checkEqual(oldvalue,0, "oldvalue");
        Tester.checkEqual(newvalue,3, "newvalue");
    }
}