From baa2728b4aaf49ac680e0e19aab9db5b26516dbc Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 15 Jan 2007 09:37:56 +0000 Subject: [PATCH] 148190#35 --- ajde/testdata/figures-coverage/.cvsignore | 1 + ajde/testdata/figures-coverage/all.lst | 8 ++ .../figures-coverage/editor/Editor.java | 4 + .../figures-coverage/figures/.cvsignore | 8 ++ .../figures-coverage/figures/Debug.java | 7 ++ .../figures-coverage/figures/Figure.java | 92 +++++++++++++++++++ .../figures/FigureElement.java | 9 ++ .../figures-coverage/figures/Main.java | 56 +++++++++++ .../figures/composites/.cvsignore | 3 + .../figures/composites/Line.java | 6 ++ .../figures/composites/Square.java | 6 ++ .../figures/primitives/planar/.cvsignore | 4 + .../figures/primitives/planar/Point.java | 73 +++++++++++++++ .../figures/primitives/solid/.cvsignore | 1 + .../figures/primitives/solid/SolidPoint.java | 24 +++++ ajde/testdata/inheritance/.cvsignore | 1 + ajde/testdata/inheritance/A.java | 22 +++++ ajde/testdata/inheritance/inheritance.lst | 1 + 18 files changed, 326 insertions(+) create mode 100644 ajde/testdata/figures-coverage/.cvsignore create mode 100644 ajde/testdata/figures-coverage/all.lst create mode 100644 ajde/testdata/figures-coverage/editor/Editor.java create mode 100644 ajde/testdata/figures-coverage/figures/.cvsignore create mode 100644 ajde/testdata/figures-coverage/figures/Debug.java create mode 100644 ajde/testdata/figures-coverage/figures/Figure.java create mode 100644 ajde/testdata/figures-coverage/figures/FigureElement.java create mode 100644 ajde/testdata/figures-coverage/figures/Main.java create mode 100644 ajde/testdata/figures-coverage/figures/composites/.cvsignore create mode 100644 ajde/testdata/figures-coverage/figures/composites/Line.java create mode 100644 ajde/testdata/figures-coverage/figures/composites/Square.java create mode 100644 ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore create mode 100644 ajde/testdata/figures-coverage/figures/primitives/planar/Point.java create mode 100644 ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore create mode 100644 ajde/testdata/figures-coverage/figures/primitives/solid/SolidPoint.java create mode 100644 ajde/testdata/inheritance/.cvsignore create mode 100644 ajde/testdata/inheritance/A.java create mode 100644 ajde/testdata/inheritance/inheritance.lst diff --git a/ajde/testdata/figures-coverage/.cvsignore b/ajde/testdata/figures-coverage/.cvsignore new file mode 100644 index 000000000..c6495af69 --- /dev/null +++ b/ajde/testdata/figures-coverage/.cvsignore @@ -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 index 000000000..3879af0b1 --- /dev/null +++ b/ajde/testdata/figures-coverage/all.lst @@ -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 index 000000000..99e2b5d5b --- /dev/null +++ b/ajde/testdata/figures-coverage/editor/Editor.java @@ -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 index 000000000..9a2b438e3 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/.cvsignore @@ -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 index 000000000..01e895abc --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/Debug.java @@ -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 index 000000000..b5e0e246a --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/Figure.java @@ -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 index 000000000..d2ce9eb82 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/FigureElement.java @@ -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 index 000000000..189f05cee --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/Main.java @@ -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 index 000000000..d9011a888 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/composites/.cvsignore @@ -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 index 000000000..1f7ee5dc8 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/composites/Line.java @@ -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 index 000000000..8ba3825d6 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/composites/Square.java @@ -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 index 000000000..1dd78c3c0 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore @@ -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 index 000000000..d389be386 --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/primitives/planar/Point.java @@ -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 index 000000000..fd0572c5e --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore @@ -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 index 000000000..80c1fc1ca --- /dev/null +++ b/ajde/testdata/figures-coverage/figures/primitives/solid/SolidPoint.java @@ -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 index 000000000..a5f90a68e --- /dev/null +++ b/ajde/testdata/inheritance/.cvsignore @@ -0,0 +1 @@ +inheritance.ajsym diff --git a/ajde/testdata/inheritance/A.java b/ajde/testdata/inheritance/A.java new file mode 100644 index 000000000..899b409f0 --- /dev/null +++ b/ajde/testdata/inheritance/A.java @@ -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 index 000000000..cf4be8246 --- /dev/null +++ b/ajde/testdata/inheritance/inheritance.lst @@ -0,0 +1 @@ +A.java -- 2.39.5