summaryrefslogtreecommitdiffstats
path: root/tests/base/test104/Driver.java
blob: 5cc2f90793b5d38d5bd0c2b31238110ddcf9cedf (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import org.aspectj.testing.Tester;

public aspect Driver {

  static boolean point, line, circle;

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

  public static void test() {
    Point p  = new Point();
    Line l   = new Line();
    Circle c = new Circle();

    Tester.check(point, "point");
    Tester.check(line, "line");
    Tester.check(circle, "circle");
  }

   before (): target(Point) && execution(new(..))  {
      point = true;
  }

   before (): target(Line) && execution(new(..)) {
      line = true; 
  }

  // the * thrown in just for fun
   before (): target(*) && target(Circle) && execution(new()) {
      circle = true;
  }
}

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; }
}

class Line {
  int _x1, _y1, _x2, _y2;

  Line() {}

  void set (int x1, int y1, int x2, int y2) {
    _x1 = x1; _y1 = y1; _x2 = x2; _y2 = y2;
  }

  void setX1 (int x1) { _x1 = x1; }
  void setY1 (int y1) { _y1 = y1; }
  void setX2 (int x2) { _x2 = x2; }
  void setY2 (int y2) { _y2 = y2; }

  int getX1() { return _x1; }
  int getY1() { return _y1; }
  int getX2() { return _x2; }
  int getY2() { return _y2; }
}

class Circle {
  int _x = 0;
  int _y = 0;
  int _r = 0;

  Circle() {}

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

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

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