]> source.dussan.org Git - aspectj.git/commitdiff
Extended test coverage.
authormkersten <mkersten>
Thu, 8 Apr 2004 23:26:41 +0000 (23:26 +0000)
committermkersten <mkersten>
Thu, 8 Apr 2004 23:26:41 +0000 (23:26 +0000)
ajdoc/testdata/coverage/fluffy/Fluffy.java [new file with mode: 0644]
ajdoc/testdata/coverage/fluffy/bunny/Bunny.java [new file with mode: 0644]
ajdoc/testdata/coverage/fluffy/bunny/rocks/Rocks.java [new file with mode: 0644]
ajdoc/testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java [new file with mode: 0644]
ajdoc/testdata/coverage/foo/ClassA.java [new file with mode: 0644]
ajdoc/testdata/coverage/foo/InterfaceI.java [new file with mode: 0644]
ajdoc/testdata/coverage/foo/ModelCoverage.java [new file with mode: 0644]
ajdoc/testdata/coverage/foo/PlainJava.java [new file with mode: 0644]
ajdoc/testdata/coverage/foo/UseThisAspectForLinkCheck.java [new file with mode: 0644]

diff --git a/ajdoc/testdata/coverage/fluffy/Fluffy.java b/ajdoc/testdata/coverage/fluffy/Fluffy.java
new file mode 100644 (file)
index 0000000..53bd7b9
--- /dev/null
@@ -0,0 +1,9 @@
+
+package fluffy;
+public class Fluffy {
+
+       void doIt() { }
+       
+}
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/fluffy/bunny/Bunny.java b/ajdoc/testdata/coverage/fluffy/bunny/Bunny.java
new file mode 100644 (file)
index 0000000..d4d44c9
--- /dev/null
@@ -0,0 +1,9 @@
+
+package fluffy.bunny;
+public class Bunny {
+
+       void doIt() { }
+       
+}
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/fluffy/bunny/rocks/Rocks.java b/ajdoc/testdata/coverage/fluffy/bunny/rocks/Rocks.java
new file mode 100644 (file)
index 0000000..28d24e6
--- /dev/null
@@ -0,0 +1,9 @@
+
+package fluffy.bunny.rocks;
+public class Rocks {
+
+       void doIt() { }
+       
+}
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java b/ajdoc/testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java
new file mode 100644 (file)
index 0000000..4936cc1
--- /dev/null
@@ -0,0 +1,13 @@
+
+package fluffy.bunny.rocks;
+
+import foo.*;
+import fluffy.*;
+import fluffy.bunny.*;
+
+public aspect UseThisAspectForLinkCheckToo {
+       
+       before(): execution(* *..*(..)) {
+               System.err.println("yo");
+       }
+} 
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/foo/ClassA.java b/ajdoc/testdata/coverage/foo/ClassA.java
new file mode 100644 (file)
index 0000000..097f4a2
--- /dev/null
@@ -0,0 +1,42 @@
+
+package foo;
+
+import java.io.IOException;
+
+/**
+ * Test class.  This is a comment.
+ */  
+public abstract class ClassA implements InterfaceI {
+       
+       /**
+        * Mumble field.
+        */
+       public String mumble = "xxx";
+       public int pubfield;
+       private String privfield = "mumble";
+        
+       public IOException exception = new IOException() {
+               
+           public String getMumble() { return "mumble"; }
+       };
+        
+       /**
+        * Mumbo. Jumbo. 
+        * 
+        * @param arg1  integer parameter
+        */ 
+       void method1(int arg1) throws IOException { 
+               pubfield = arg1;
+       }
+       
+       public void foo() { }
+       
+       static aspect InnerAspect {
+               String s;
+       }
+}
+class SubClass extends ClassA { 
+        
+       public void foo() { }
+}
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/foo/InterfaceI.java b/ajdoc/testdata/coverage/foo/InterfaceI.java
new file mode 100644 (file)
index 0000000..55b0181
--- /dev/null
@@ -0,0 +1,6 @@
+
+package foo;
+
+public interface InterfaceI { 
+       void foo();
+} 
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/foo/ModelCoverage.java b/ajdoc/testdata/coverage/foo/ModelCoverage.java
new file mode 100644 (file)
index 0000000..5c14055
--- /dev/null
@@ -0,0 +1,150 @@
+
+package foo;
+
+import java.io.*;
+import java.util.List;
+interface I { } 
+
+class Point { 
+       int x;
+       static int sx;
+
+       { 
+               System.out.println(""); 
+       } 
+
+       { x = 0; }
+       static { sx = 1; }
+       
+       public Point() { }
+       
+       public int getX() { 
+               return x;       
+       }
+       
+       public void setX(int x) { 
+               this.x = x; 
+       }
+        
+       public int changeX(int x) { 
+               this.x = x;
+               return x;
+       }
+       
+       void doIt() { 
+               try {
+                       File f = new File(".");
+                       f.getCanonicalPath();
+               } catch (IOException ioe) {
+                       System.err.println("!");        
+               }       
+//             setX(10);
+               new Point();
+       }
+} 
+
+class SubPoint extends Point { }
+
+class Line { }
+
+aspect AdvisesRelationshipCoverage {
+       pointcut methodExecutionP(): execution(void Point.setX(int));
+       before(): methodExecutionP() { }
+  
+       pointcut constructorExecutionP(): execution(Point.new());
+       before(): constructorExecutionP() { }
+
+       pointcut callMethodP(): call(* Point.setX(int));
+       before(): callMethodP() { }
+
+       pointcut callConstructorP(): call(Point.new());
+       before(): callConstructorP() { }
+
+       pointcut getP(): get(int *.*);
+       before(): getP() { }
+
+       pointcut setP(): set(int *.*) && !set(int *.xxx);
+       before(): setP() { }
+
+       pointcut initializationP(): initialization(Point.new(..));
+       before(): initializationP() { }
+
+       pointcut staticinitializationP(): staticinitialization(Point);
+       before(): staticinitializationP() { }
+
+       pointcut handlerP(): handler(IOException);
+       before(): handlerP() { }
+
+//    before(): within(*) && execution(* Point.setX(..)) { }
+//    before(): within(*) && execution(Point.new()) { }
+}
+
+aspect AdviceNamingCoverage {
+       pointcut named(): call(* *.mumble());
+       pointcut namedWithOneArg(int i): call(int Point.changeX(int)) && args(i);
+       pointcut namedWithArgs(int i, int j): set(int Point.x) && args(i, j);
+
+       after(): named() { }    
+       after(int i, int j) returning: namedWithArgs(i, j) { }
+       after() throwing: named() { }
+       after(): named() { } 
+       
+       before(): named() { }
+       
+       int around(int i): namedWithOneArg(i) { return i;}
+       int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); }
+       
+       before(): named() { }   
+       before(int i): call(* *.mumble()) && named() && namedWithOneArg(i) { }  
+       before(int i): named() && call(* *.mumble()) && namedWithOneArg(i) { }  
+       
+       before(): call(* *.mumble()) { }
+}
+  
+abstract aspect AbstractAspect {
+       abstract pointcut abPtct();     
+}
+  
+aspect InterTypeDecCoverage {
+    public int Point.xxx = 0;
+    public int Point.check(int i, Line l) { return 1 + i; }
+}
+
+aspect DeclareCoverage {
+
+    pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..));
+
+    declare error: illegalNewFigElt(): "Illegal constructor call.";
+    declare warning: call(* Point.setX(..)): "Illegal call.";
+
+    declare parents: Point extends java.io.Serializable;
+    declare parents: Point+ implements java.util.Observable;
+       declare parents: Point && Line implements java.util.Observable;
+    declare soft: SizeException : call(* Point.getX());
+       declare precedence: AdviceCoverage, InterTypeDecCoverage, *;
+//     public Line.new(String s) {  }
+}
+
+class SizeException extends Exception { } 
+
+aspect AdviceCoverage {
+
+}
+
+abstract class ModifiersCoverage {
+       private int a;
+       protected int b;
+       public int c;
+       int d;
+
+       static int staticA;
+       final int finalA = 0;
+       
+       abstract void abstractM();
+}
+
+
+
+
+
diff --git a/ajdoc/testdata/coverage/foo/PlainJava.java b/ajdoc/testdata/coverage/foo/PlainJava.java
new file mode 100644 (file)
index 0000000..3c1314c
--- /dev/null
@@ -0,0 +1,35 @@
+
+package foo;
+
+import java.io.*;
+
+public class PlainJava {
+       public int i;
+        
+       /**
+     * Mark that the transaction is "poisoned". I.e., it will have to rollback.
+     * If commit() is called, the transaction will roll back instead.
+        */
+       public int getI() { 
+               assert true;
+               
+               new FileFilter() {
+                       public boolean accept(File f) {
+                               boolean accept = !(f.isDirectory() || f.getName().endsWith(".class")) ;
+                               return accept;
+                       }  
+               };
+               
+               return i; 
+       }
+       
+       static private class Bar {
+               
+               static private class Baz { 
+
+                       static private class Jazz { 
+                               void mumble() { }
+                       }
+               }
+       }
+} 
\ No newline at end of file
diff --git a/ajdoc/testdata/coverage/foo/UseThisAspectForLinkCheck.java b/ajdoc/testdata/coverage/foo/UseThisAspectForLinkCheck.java
new file mode 100644 (file)
index 0000000..6130483
--- /dev/null
@@ -0,0 +1,21 @@
+
+package foo;
+
+import fluffy.*;
+import fluffy.bunny.*;
+import fluffy.bunny.rocks.*;
+
+public aspect UseThisAspectForLinkCheck {
+       
+       int foo;
+       
+       pointcut allExecutions(): execution(* *..*(..));
+       
+       before(): allExecutions() {
+               System.err.println("yo");
+       }
+       after(): allExecutions() {
+               System.err.println("go");
+       }
+} 
\ No newline at end of file