From db5cc21f2429dfa9b490d924997927dcfcc4952b Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 12 Dec 2008 17:14:00 +0000 Subject: [PATCH] fq itds - tests --- tests/multiIncremental/itdfq/base/src/A.java | 17 ++++ .../multiIncremental/itdpe/base/test/Demo.aj | 12 +++ .../itdpe/base/test/MyAspect.aj | 36 ++++++++ .../itdpe/base/test/OtherClass.aj | 9 ++ .../itdpe/base/test2/MyAspect2.aj | 28 +++++++ .../itdpe/base/test2/OtherClass2.aj | 13 +++ .../tools/MultiProjectIncrementalTests.java | 82 +++++++++++++++++++ 7 files changed, 197 insertions(+) create mode 100644 tests/multiIncremental/itdfq/base/src/A.java create mode 100644 tests/multiIncremental/itdpe/base/test/Demo.aj create mode 100644 tests/multiIncremental/itdpe/base/test/MyAspect.aj create mode 100644 tests/multiIncremental/itdpe/base/test/OtherClass.aj create mode 100644 tests/multiIncremental/itdpe/base/test2/MyAspect2.aj create mode 100644 tests/multiIncremental/itdpe/base/test2/OtherClass2.aj diff --git a/tests/multiIncremental/itdfq/base/src/A.java b/tests/multiIncremental/itdfq/base/src/A.java new file mode 100644 index 000000000..2e2478416 --- /dev/null +++ b/tests/multiIncremental/itdfq/base/src/A.java @@ -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 index 000000000..4a8355fd3 --- /dev/null +++ b/tests/multiIncremental/itdpe/base/test/Demo.aj @@ -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 index 000000000..7b15897dc --- /dev/null +++ b/tests/multiIncremental/itdpe/base/test/MyAspect.aj @@ -0,0 +1,36 @@ +package test; +import java.util.List; + +public aspect MyAspect { + List Demo.list = null; + int Demo.x = 5; + + void Demo.foo(List 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 index 000000000..2a24fd6f9 --- /dev/null +++ b/tests/multiIncremental/itdpe/base/test/OtherClass.aj @@ -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 index 000000000..8fd933a34 --- /dev/null +++ b/tests/multiIncremental/itdpe/base/test2/MyAspect2.aj @@ -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 index 000000000..052219d7e --- /dev/null +++ b/tests/multiIncremental/itdpe/base/test2/OtherClass2.aj @@ -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(); + } +} diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index d5760ad61..2cd1ca90b 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -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