]> source.dussan.org Git - aspectj.git/commitdiff
fq itds - tests
authoraclement <aclement>
Fri, 12 Dec 2008 17:14:00 +0000 (17:14 +0000)
committeraclement <aclement>
Fri, 12 Dec 2008 17:14:00 +0000 (17:14 +0000)
tests/multiIncremental/itdfq/base/src/A.java [new file with mode: 0644]
tests/multiIncremental/itdpe/base/test/Demo.aj [new file with mode: 0644]
tests/multiIncremental/itdpe/base/test/MyAspect.aj [new file with mode: 0644]
tests/multiIncremental/itdpe/base/test/OtherClass.aj [new file with mode: 0644]
tests/multiIncremental/itdpe/base/test2/MyAspect2.aj [new file with mode: 0644]
tests/multiIncremental/itdpe/base/test2/OtherClass2.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

diff --git a/tests/multiIncremental/itdfq/base/src/A.java b/tests/multiIncremental/itdfq/base/src/A.java
new file mode 100644 (file)
index 0000000..2e24784
--- /dev/null
@@ -0,0 +1,17 @@
+package a.b.c;
+
+public class A {
+}
+
+aspect X {
+  B A.foo(C c) { return null; }
+  declare parents: A implements java.io.Serializable;
+}
+
+class B {}
+
+class C {}
+
+aspect XX {
+  public B.new(String s) {}
+}
diff --git a/tests/multiIncremental/itdpe/base/test/Demo.aj b/tests/multiIncremental/itdpe/base/test/Demo.aj
new file mode 100644 (file)
index 0000000..4a8355f
--- /dev/null
@@ -0,0 +1,12 @@
+package test;
+
+
+public class Demo {
+    
+    void g() {
+        new Demo(7).foo(null);
+        x++;
+        this.x++;
+    }
+
+}
diff --git a/tests/multiIncremental/itdpe/base/test/MyAspect.aj b/tests/multiIncremental/itdpe/base/test/MyAspect.aj
new file mode 100644 (file)
index 0000000..7b15897
--- /dev/null
@@ -0,0 +1,36 @@
+package test;
+import java.util.List;
+
+public aspect MyAspect {
+    List<String> Demo.list = null;
+       int Demo.x = 5;
+       
+       void Demo.foo(List<String> x) {
+               
+       }
+       
+       public Demo.new(int x) { }
+       
+    declare warning : execution(* *.nothing(..)) : "blah";
+    
+    declare error : execution(* *.nothing(..)) : "blah";
+    
+       declare soft : Exception : execution(* *.nothing(..));
+       
+       
+    protected pointcut s():
+        call(String Demo.toString(..));
+
+    before (): s() {
+    }
+    after (): s() {
+    }
+    void around (): s() {
+        proceed();
+        return;
+    }
+    after () returning(): s() {
+    }
+    after () throwing(): s() {
+    }
+}
diff --git a/tests/multiIncremental/itdpe/base/test/OtherClass.aj b/tests/multiIncremental/itdpe/base/test/OtherClass.aj
new file mode 100644 (file)
index 0000000..2a24fd6
--- /dev/null
@@ -0,0 +1,9 @@
+package test;
+
+public class OtherClass {
+    void x() {
+        Demo d = new Demo(4);
+        d.foo(null);
+        d.x ++;
+    }
+}
diff --git a/tests/multiIncremental/itdpe/base/test2/MyAspect2.aj b/tests/multiIncremental/itdpe/base/test2/MyAspect2.aj
new file mode 100644 (file)
index 0000000..8fd933a
--- /dev/null
@@ -0,0 +1,28 @@
+package test2;
+
+public aspect MyAspect2 {
+    
+    static interface Bar {
+        
+    }
+    static class Foo {
+        public Foo() {
+            
+        }
+    }
+    
+    // must use fully qualified names
+    declare parents : test.Demo implements test2.MyAspect2.Bar, Cloneable;
+    
+    // must use fully qualified names
+    declare parents : test.Demo extends test2.MyAspect2.Foo;
+    
+    int Bar.bar() { 
+        return 7;
+    }
+    
+    int Foo.baz() {
+        return 7;
+    }
+    
+}
diff --git a/tests/multiIncremental/itdpe/base/test2/OtherClass2.aj b/tests/multiIncremental/itdpe/base/test2/OtherClass2.aj
new file mode 100644 (file)
index 0000000..052219d
--- /dev/null
@@ -0,0 +1,13 @@
+package test2;
+
+import test.Demo;
+
+public class OtherClass2 {
+    void x() {
+        Demo d = new Demo(4);
+        ((MyAspect2.Bar) d).bar();
+        d.baz();
+        
+        ((Cloneable) d).toString();
+    }
+}
index d5760ad61379477e46347fc38ae8e175d58f8fdb..2cd1ca90bc0c55b297e6a130a9b2bafa608e1a28 100644 (file)
@@ -19,6 +19,7 @@ import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.aspectj.ajde.core.ICompilerConfiguration;
@@ -30,6 +31,7 @@ import org.aspectj.asm.IHierarchy;
 import org.aspectj.asm.IProgramElement;
 import org.aspectj.asm.IRelationship;
 import org.aspectj.asm.IRelationshipMap;
+import org.aspectj.asm.internal.ProgramElement;
 import org.aspectj.asm.internal.Relationship;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.tools.ajc.Ajc;
@@ -164,6 +166,86 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                checkCompileWeaveCount("Annos", 3, 3);
        }
 
+       
+       // package a.b.c;
+       //
+       // public class A {
+       // }
+       //
+       // aspect X {
+       // B A.foo(C c) { return null; }
+       // declare parents: A implements java.io.Serializable;
+       // }
+       //
+       // class B {}
+       // class C {}
+       public void testITDFQNames_pr252702() {
+               String p = "itdfq";
+               AjdeInteractionTestbed.VERBOSE = true;
+               initialiseProject(p);
+               build(p);
+               AsmManager model = getModelFor(p);
+               dumptree(model.getHierarchy().getRoot(), 0);
+               IProgramElement root = model.getHierarchy().getRoot();
+               ProgramElement theITD = (ProgramElement) findElementAtLine(root, 7);
+               Map m = theITD.kvpairs;
+               for (Iterator iterator = m.keySet().iterator(); iterator.hasNext();) {
+                       String type = (String) iterator.next();
+                       System.out.println(type + " = " + m.get(type));
+               }
+               // return type of the ITD
+               assertEquals("a.b.c.B", theITD.getCorrespondingType(true));
+               List ptypes = theITD.getParameterTypes();
+               for (Iterator iterator = ptypes.iterator(); iterator.hasNext();) {
+                       char[] object = (char[]) iterator.next();
+                       System.out.println("p = " + new String(object));
+               }
+               ProgramElement decp = (ProgramElement) findElementAtLine(root, 8);
+               m = decp.kvpairs;
+               for (Iterator iterator = m.keySet().iterator(); iterator.hasNext();) {
+                       String type = (String) iterator.next();
+                       System.out.println(type + " = " + m.get(type));
+               }
+               List l = decp.getParentTypes();
+               assertEquals("java.io.Serializable", (String) l.get(0));
+               ProgramElement ctorDecp = (ProgramElement) findElementAtLine(root, 16);
+               String ctordecphandle = ctorDecp.getHandleIdentifier();
+               assertEquals("=itdfq<a.b.c{A.java}XX)B.B_new)QString;", ctordecphandle); // 252702, comment 7
+       }
+
+       public void testItdProgramElement_pr252702() {
+               String p = "itdpe";
+               AjdeInteractionTestbed.VERBOSE = true;
+               initialiseProject(p);
+               build(p);
+               AsmManager model = getModelFor(p);
+               dumptree(model.getHierarchy().getRoot(), 0);
+               IProgramElement root = model.getHierarchy().getRoot();
+               ProgramElement theITD = (ProgramElement) findElementAtLine(root, 7);
+               Map m = theITD.kvpairs;
+               for (Iterator iterator = m.keySet().iterator(); iterator.hasNext();) {
+                       String type = (String) iterator.next();
+                       System.out.println(type + " = " + m.get(type));
+               }
+               // return type of the ITD
+               assertEquals("a.b.c.B", theITD.getCorrespondingType(true));
+               List ptypes = theITD.getParameterTypes();
+               for (Iterator iterator = ptypes.iterator(); iterator.hasNext();) {
+                       char[] object = (char[]) iterator.next();
+                       System.out.println("p = " + new String(object));
+               }
+               ProgramElement decp = (ProgramElement) findElementAtLine(root, 8);
+               m = decp.kvpairs;
+               for (Iterator iterator = m.keySet().iterator(); iterator.hasNext();) {
+                       String type = (String) iterator.next();
+                       System.out.println(type + " = " + m.get(type));
+               }
+               List l = decp.getParentTypes();
+               assertEquals("java.io.Serializable", (String) l.get(0));
+
+               // 
+       }
+
        public void testBrokenHandles_pr247742() {
                String p = "BrokenHandles";
                initialiseProject(p);