aboutsummaryrefslogtreecommitdiffstats
path: root/testing/figures-coverage/figures/Figure.java
blob: b5e0e246a2a469a690570f3a4c3f51b54bf3dbd0 (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
89
90
91
92
package figures;

import figures.primitives.planar.Point;

import java.awt.Canvas;

aspect Figure {
    //pointcut sendSuccess(): cflow(setX()) && !handler(Exception);

    public String Point.getName() {
        return Point.name;
    } 

    public int figures.primitives.planar.Point.DEFAULT_X = 0; 

    public pointcut constructions(): call(Point.new(int, int)) || call(SolidPoint.new(int, int, int));

    public pointcut moves(FigureElement fe): target(fe) &&
        (call(String Point.getName()) ||
	 call(void FigureElement.incrXY(int, int)) ||
         call(void Point.setX(int)) ||
         call(void Point.setY(int)) ||
         call(void SolidPoint.setZ(int)));
    
    pointcut mainExecution(): 
	execution(int main(*));

    pointcut runtimeHandlers(): mainExecution() 
	|| handler(RuntimeException);

    public pointcut mumble(): runtimeHandlers();

    before(int newValue): set(int *.*) && args(newValue) {   }

    before(): get(int *.*) { }

    before(): constructions() {
	    System.out.println("> before construction, jp: " + thisJoinPoint.getSignature());
    } 

    before(FigureElement fe): moves(fe) {
	    System.out.println("> about to move FigureElement at X-coord: ");
	}

    after(): initialization(Point.new(..)) || staticinitialization(Point) {
        System.out.println("> Point initialized");
    }

    // should be around
    after(): mumble() {
        System.err.println(">> in after advice...");
        //proceed();
    }

    after(FigureElement fe): target(fe) &&
        (call(void FigureElement.incrXY(int, int)) ||
         call(void Point.setX(int)) ||
         call(void Point.setY(int)) ||
         call(void SolidPoint.setZ(int))) {
        System.out.println("> yo.");
    }

    after(FigureElement fe):
	target(fe) &&
	(call(void FigureElement.incrXY(int, int)) ||
	 call(void Line.setP1(Point))              ||
	 call(void Line.setP2(Point))              ||
	 call(void Point.setX(int))                ||
	 call(void Point.setY(int))) { }

    declare parents: Point extends java.io.Serializable;

    declare parents: Point implements java.util.Observable;

	// AMC - this next line doesn't make sense!! Can these tests ever
	// have been run???
    //declare soft: Point: call(* *(..));
}

aspect Checks {
    pointcut illegalNewFigElt():  call(FigureElement+.new(..))  &&
	                          !withincode(* Main.main(..));

//	pointcut illegalNewFigElt(): execution(FigureElement+.new(..));

    declare error: illegalNewFigElt():
	    "Illegal figure element constructor call.";

    declare warning: illegalNewFigElt():
	    "Illegal figure element constructor call.";
}