]> source.dussan.org Git - aspectj.git/commitdiff
148190#35
authoraclement <aclement>
Mon, 15 Jan 2007 09:37:56 +0000 (09:37 +0000)
committeraclement <aclement>
Mon, 15 Jan 2007 09:37:56 +0000 (09:37 +0000)
18 files changed:
ajde/testdata/figures-coverage/.cvsignore [new file with mode: 0644]
ajde/testdata/figures-coverage/all.lst [new file with mode: 0644]
ajde/testdata/figures-coverage/editor/Editor.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/.cvsignore [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/Debug.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/Figure.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/FigureElement.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/Main.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/composites/.cvsignore [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/composites/Line.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/composites/Square.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/primitives/planar/Point.java [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore [new file with mode: 0644]
ajde/testdata/figures-coverage/figures/primitives/solid/SolidPoint.java [new file with mode: 0644]
ajde/testdata/inheritance/.cvsignore [new file with mode: 0644]
ajde/testdata/inheritance/A.java [new file with mode: 0644]
ajde/testdata/inheritance/inheritance.lst [new file with mode: 0644]

diff --git a/ajde/testdata/figures-coverage/.cvsignore b/ajde/testdata/figures-coverage/.cvsignore
new file mode 100644 (file)
index 0000000..c6495af
--- /dev/null
@@ -0,0 +1 @@
+all.ajsym
diff --git a/ajde/testdata/figures-coverage/all.lst b/ajde/testdata/figures-coverage/all.lst
new file mode 100644 (file)
index 0000000..3879af0
--- /dev/null
@@ -0,0 +1,8 @@
+figures/Debug.java
+figures/Figure.java
+figures/FigureElement.java
+figures/Main.java
+figures/composites/Line.java
+figures/composites/Square.java
+figures/primitives/planar/Point.java
+figures/primitives/solid/SolidPoint.java
diff --git a/ajde/testdata/figures-coverage/editor/Editor.java b/ajde/testdata/figures-coverage/editor/Editor.java
new file mode 100644 (file)
index 0000000..99e2b5d
--- /dev/null
@@ -0,0 +1,4 @@
+
+package editor;
+
+class Editor { }
diff --git a/ajde/testdata/figures-coverage/figures/.cvsignore b/ajde/testdata/figures-coverage/figures/.cvsignore
new file mode 100644 (file)
index 0000000..9a2b438
--- /dev/null
@@ -0,0 +1,8 @@
+Checks.class
+Debug.class
+Element.class
+Figure.class
+FigureElement.class
+Main.class
+Main$TestGUI.class
+Test.class
diff --git a/ajde/testdata/figures-coverage/figures/Debug.java b/ajde/testdata/figures-coverage/figures/Debug.java
new file mode 100644 (file)
index 0000000..01e895a
--- /dev/null
@@ -0,0 +1,7 @@
+
+package figures;
+
+aspect Debug {
+
+}
+
diff --git a/ajde/testdata/figures-coverage/figures/Figure.java b/ajde/testdata/figures-coverage/figures/Figure.java
new file mode 100644 (file)
index 0000000..b5e0e24
--- /dev/null
@@ -0,0 +1,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.";
+}
diff --git a/ajde/testdata/figures-coverage/figures/FigureElement.java b/ajde/testdata/figures-coverage/figures/FigureElement.java
new file mode 100644 (file)
index 0000000..d2ce9eb
--- /dev/null
@@ -0,0 +1,9 @@
+
+package figures;
+
+public interface FigureElement extends Element {
+
+    public void incrXY(int dx, int dy);
+}
+
+interface Element { }
diff --git a/ajde/testdata/figures-coverage/figures/Main.java b/ajde/testdata/figures-coverage/figures/Main.java
new file mode 100644 (file)
index 0000000..189f05c
--- /dev/null
@@ -0,0 +1,56 @@
+
+package figures;
+
+import figures.primitives.planar.Point;
+import figures.primitives.solid.SolidPoint;
+
+class Main {
+
+    private static Point startPoint;
+
+    public static void main(String[] args) {
+        try {
+            System.out.println("> starting...");
+
+            startPoint = makeStartPoint();
+            //startPoint.setX(3); new Point(0, 0);
+//             SolidPoint sp1 = new SolidPoint(1, 3, 3);
+
+//             sp1.setZ(1);
+//             p1.incrXY(3, 3);
+        } catch (RuntimeException re) {
+            re.printStackTrace();
+        }
+        System.out.println("> finished.");
+    }
+
+    /** @deprecated     use something else */
+    public static Point makeStartPoint() {
+        //return new Point(1, 2);
+         return null;
+    }
+
+    /** This should produce a deprecation warning with JDK > 1.2 */
+    static class TestGUI extends javax.swing.JFrame {
+        TestGUI() {
+           this.disable();
+        }
+    }
+
+    /** This should produce a porting-deprecation warning. */
+    //static pointcut mainExecution(): execution(void main(*));
+}
+
+privileged aspect Test {
+    pointcut testptct(): call(* *.*(..));
+
+    before(Point p, int newval): target(p) && set(int Point.xx) && args(newval) {
+        System.err.println("> new value of x is: " + p.x + ", setting to: " + newval);
+    }
+
+       before(int newValue): set(int Point.*) && args(newValue) {
+           if (newValue < 0) {
+               throw new IllegalArgumentException("too small");
+           } 
+       }
+}
diff --git a/ajde/testdata/figures-coverage/figures/composites/.cvsignore b/ajde/testdata/figures-coverage/figures/composites/.cvsignore
new file mode 100644 (file)
index 0000000..d9011a8
--- /dev/null
@@ -0,0 +1,3 @@
+BoundedLine.class
+Line.class
+Square.class
diff --git a/ajde/testdata/figures-coverage/figures/composites/Line.java b/ajde/testdata/figures-coverage/figures/composites/Line.java
new file mode 100644 (file)
index 0000000..1f7ee5d
--- /dev/null
@@ -0,0 +1,6 @@
+
+package figures.composites;
+
+class Line { }
+
+class BoundedLine extends Line { } 
diff --git a/ajde/testdata/figures-coverage/figures/composites/Square.java b/ajde/testdata/figures-coverage/figures/composites/Square.java
new file mode 100644 (file)
index 0000000..8ba3825
--- /dev/null
@@ -0,0 +1,6 @@
+
+package figures.composites;
+
+class Square { 
+   private String name = "Square";
+}
diff --git a/ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore b/ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore
new file mode 100644 (file)
index 0000000..1dd78c3
--- /dev/null
@@ -0,0 +1,4 @@
+StrictlyBoundedPoint.class
+PointBoundsException.class
+Point.class
+BoundedPoint.class
diff --git a/ajde/testdata/figures-coverage/figures/primitives/planar/Point.java b/ajde/testdata/figures-coverage/figures/primitives/planar/Point.java
new file mode 100644 (file)
index 0000000..d389be3
--- /dev/null
@@ -0,0 +1,73 @@
+
+package figures.primitives.planar;
+
+import figures.*;
+import java.util.Collection;
+
+public class Point implements FigureElement {
+
+    static int xx = -1;
+    private int x;
+    private int y;
+    transient int currVal = 0;
+    public static String name;  
+
+    { 
+       y = -1;
+    }
+
+    static {
+       xx = -10;
+    }
+
+    int c; int b; int a; 
+    {
+        x = 0;
+        y = 0;
+    }
+
+    static {
+        Point.name = "2-Dimensional Point";
+    }
+
+    public Point(int x, int y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    int getCurrVal() {
+       return currVal;
+    }
+
+    /**
+     * @see Figure#moves
+     */
+    public int getX() { return x; }
+
+    public int getY() { return y; }
+
+    public void setX(int x) { this.x = x; }
+
+    public void setY(int x) { this.y = x; }
+
+    public void incrXY(int dx, int dy) {
+        setX(getX() + dx);
+        setY(getY() + dy);
+    }
+    public void check(int dx, int dy) 
+       throws ArithmeticException, PointBoundsException {
+       if (dx < 0 || dy < 0) throw new PointBoundsException();
+    }
+}
+
+class PointBoundsException extends Exception { }
+
+class BoundedPoint extends Point { 
+    public BoundedPoint(int x, int y) { super(x, y); }
+}
+
+class StrictlyBoundedPoint extends BoundedPoint { 
+    public StrictlyBoundedPoint(int x, int y) { super(x, y); }
+}
+
+
diff --git a/ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore b/ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore
new file mode 100644 (file)
index 0000000..fd0572c
--- /dev/null
@@ -0,0 +1 @@
+SolidPoint.class
diff --git a/ajde/testdata/figures-coverage/figures/primitives/solid/SolidPoint.java b/ajde/testdata/figures-coverage/figures/primitives/solid/SolidPoint.java
new file mode 100644 (file)
index 0000000..80c1fc1
--- /dev/null
@@ -0,0 +1,24 @@
+
+package figures.primitives.solid;
+
+import java.util.Collection;
+import java.lang.String;
+import figures.primitives.planar.*;
+
+public class SolidPoint extends Point {
+    private int z;
+
+    public SolidPoint(int x, int y, int z) {
+        super(x, y);
+        this.z = z;
+    }
+
+    public int getZ() { return z; }
+
+    public void setZ(int z) { this.z = z; }
+
+    public void incrXY(int dx, int dy) {
+        super.incrXY(dx, dy);
+        setZ(getZ() + dx + dy);
+    }
+}
diff --git a/ajde/testdata/inheritance/.cvsignore b/ajde/testdata/inheritance/.cvsignore
new file mode 100644 (file)
index 0000000..a5f90a6
--- /dev/null
@@ -0,0 +1 @@
+inheritance.ajsym
diff --git a/ajde/testdata/inheritance/A.java b/ajde/testdata/inheritance/A.java
new file mode 100644 (file)
index 0000000..899b409
--- /dev/null
@@ -0,0 +1,22 @@
+
+package inheritance;
+
+public abstract class A {
+
+       public abstract void bar();
+
+       public void foo() { }
+       
+       public String toString() { 
+               // mumble
+
+               return ""; 
+       } 
+}
+
+class B extends A {
+       
+       public void bar() { }
+       
+       public void foo() { }
+}
diff --git a/ajde/testdata/inheritance/inheritance.lst b/ajde/testdata/inheritance/inheritance.lst
new file mode 100644 (file)
index 0000000..cf4be82
--- /dev/null
@@ -0,0 +1 @@
+A.java