aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraclement <aclement>2006-08-25 12:37:49 +0000
committeraclement <aclement>2006-08-25 12:37:49 +0000
commit07e6e9a1767c860b483540ac165108983dc1e1f4 (patch)
treefd180b83ddb86ca9637df6afd9b1d75bb7c1a4a3 /tests
parent5787d0e82f32648f30f4677c13aef68d4615e300 (diff)
downloadaspectj-07e6e9a1767c860b483540ac165108983dc1e1f4.tar.gz
aspectj-07e6e9a1767c860b483540ac165108983dc1e1f4.zip
last of the dreaded jdtlikehandleprovider changes - 141730#22
Diffstat (limited to 'tests')
-rw-r--r--tests/features153/jdtlikehandleprovider/Get.aj20
-rw-r--r--tests/features153/jdtlikehandleprovider/Handler.aj30
-rw-r--r--tests/features153/jdtlikehandleprovider/Set.aj19
-rw-r--r--tests/features153/jdtlikehandleprovider/TwoDiffMethodCalls.aj25
-rw-r--r--tests/features153/jdtlikehandleprovider/TwoMethodCalls.aj23
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java75
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml20
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java9
8 files changed, 219 insertions, 2 deletions
diff --git a/tests/features153/jdtlikehandleprovider/Get.aj b/tests/features153/jdtlikehandleprovider/Get.aj
new file mode 100644
index 000000000..cb300ff34
--- /dev/null
+++ b/tests/features153/jdtlikehandleprovider/Get.aj
@@ -0,0 +1,20 @@
+aspect A1 {
+
+ pointcut getPcd() : get(int C1.x);
+
+ before() : getPcd() {
+ }
+
+}
+
+class C1 {
+
+ int x = 0;
+
+ public void method1() {
+ int y = x;
+ System.out.println("y " + y);
+ int z = x;
+ System.out.println("z " + z);
+ }
+}
diff --git a/tests/features153/jdtlikehandleprovider/Handler.aj b/tests/features153/jdtlikehandleprovider/Handler.aj
new file mode 100644
index 000000000..24bbeabb5
--- /dev/null
+++ b/tests/features153/jdtlikehandleprovider/Handler.aj
@@ -0,0 +1,30 @@
+import java.io.FileNotFoundException;
+
+aspect A {
+
+ pointcut handlerPointcut() : handler(FileNotFoundException);
+
+ before() : handlerPointcut() {
+ }
+
+}
+
+class C {
+
+ public void method() {
+ try {
+ exceptionMethod();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ try {
+ exceptionMethod();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void exceptionMethod() throws FileNotFoundException {
+ }
+}
diff --git a/tests/features153/jdtlikehandleprovider/Set.aj b/tests/features153/jdtlikehandleprovider/Set.aj
new file mode 100644
index 000000000..d7822f172
--- /dev/null
+++ b/tests/features153/jdtlikehandleprovider/Set.aj
@@ -0,0 +1,19 @@
+aspect A1 {
+
+ pointcut setPcd() : set(int C1.x);
+
+ before() : setPcd() {
+ }
+
+}
+
+class C1 {
+
+ int x = 0;
+
+ public void method() {
+ x = 1;
+ x = 2;
+ }
+
+}
diff --git a/tests/features153/jdtlikehandleprovider/TwoDiffMethodCalls.aj b/tests/features153/jdtlikehandleprovider/TwoDiffMethodCalls.aj
new file mode 100644
index 000000000..b024974c4
--- /dev/null
+++ b/tests/features153/jdtlikehandleprovider/TwoDiffMethodCalls.aj
@@ -0,0 +1,25 @@
+aspect A {
+
+ pointcut tracedPrint(String s): call(void java.io.PrintStream.println(*)) &&
+ args(s) && !within(A);
+
+ before(String s): tracedPrint(s) {
+ System.out.println("got you: " + s + " ;)");
+ }
+
+ after(String s): tracedPrint(s) {
+ System.out.println("hehe, finished: " + s + " :(");
+ }
+}
+
+class Main {
+
+ public static void main(String[] args) {
+ System.out.println("start");
+ }
+
+ public void method(String[] s) {
+ System.out.println("end");
+ }
+
+}
diff --git a/tests/features153/jdtlikehandleprovider/TwoMethodCalls.aj b/tests/features153/jdtlikehandleprovider/TwoMethodCalls.aj
new file mode 100644
index 000000000..fb7bd140e
--- /dev/null
+++ b/tests/features153/jdtlikehandleprovider/TwoMethodCalls.aj
@@ -0,0 +1,23 @@
+aspect A {
+
+ pointcut tracedPrint(String s): call(void java.io.PrintStream.println(*)) &&
+ args(s) && !within(A);
+
+ before(String s): tracedPrint(s) {
+ System.out.println("got you: " + s + " ;)");
+ }
+
+ after(String s): tracedPrint(s) {
+ System.out.println("hehe, finished: " + s + " :(");
+ }
+}
+
+class Main {
+
+ public static void main(String[] args) {
+ System.out.println("start");
+ System.out.println("end");
+ }
+
+}
+
diff --git a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
index 0e6b70166..4dd33640e 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc153/JDTLikeHandleProviderTests.java
@@ -240,6 +240,81 @@ public class JDTLikeHandleProviderTests extends XMLBasedAjcTestCase {
"*DeclareWarnings.aj}DeclareWarnings`declare warning!10");
}
+
+ // these two handles are the same unless we have added a counter
+ // on the end
+ public void testIPEsWithSameNameHaveUniqueHandles_methodCall() {
+ runTest("ipes with same name have unique handles - method-call");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String handle1 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" +
+ "void java.io.PrintStream.println(java.lang.String))";
+ assertNotNull("expected to find node with handle " + handle1
+ + ", but did not",top.getElement(handle1));
+
+ String handle2 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" +
+ "void java.io.PrintStream.println(java.lang.String))!2";
+ assertNotNull("expected to find node with handle " + handle2
+ + ", but did not",top.getElement(handle2));
+
+ String handle3 = "*TwoMethodCalls.aj[Main~main~\\[QString;?method-call(" +
+ "void java.io.PrintStream.println(java.lang.String))!3";
+ assertNull("expected not to find node with handle " + handle3
+ + ", but found one",top.getElement(handle3));
+ }
+
+ // these two handles should be different anyway so second one
+ // shouldn't have the "2"
+ public void testIPEsWithDiffNamesDontHaveCounter_methodCall() {
+ runTest("ipes with different names do not have counter - method-call");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String handle1 = "*TwoDiffMethodCalls.aj[Main~main~\\[QString;?method-call(" +
+ "void java.io.PrintStream.println(java.lang.String))";
+ assertNotNull("expected to find node with handle " + handle1
+ + ", but did not",top.getElement(handle1));
+
+ String handle2 = "*TwoDiffMethodCalls.aj[Main~method~\\[QString;?method-call(" +
+ "void java.io.PrintStream.println(java.lang.String))";
+ assertNotNull("expected to find node with handle " + handle2
+ + ", but did not",top.getElement(handle2));
+ }
+
+ public void testIPEsWithSameNameHaveUniqueHandles_handler() {
+ runTest("ipes with same name have unique handles - handler");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String handle1 = "*Handler.aj[C~method?exception-handler(void C." +
+ "<catch>(java.io.FileNotFoundException))";
+ assertNotNull("expected to find node with handle " + handle1
+ + ", but did not",top.getElement(handle1));
+
+ String handle2 = "*Handler.aj[C~method?exception-handler(void C." +
+ "<catch>(java.io.FileNotFoundException))!2";
+ assertNotNull("expected to find node with handle " + handle2
+ + ", but did not",top.getElement(handle2));
+ }
+
+ public void testIPEsWithSameNameHaveUniqueHandles_get() {
+ runTest("ipes with same name have unique handles - get");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String handle1 = "*Get.aj[C1~method1?field-get(int C1.x)";
+ assertNotNull("expected to find node with handle " + handle1
+ + ", but did not",top.getElement(handle1));
+
+ String handle2 = "*Get.aj[C1~method1?field-get(int C1.x)!2";
+ assertNotNull("expected to find node with handle " + handle2
+ + ", but did not",top.getElement(handle2));
+ }
+
+ public void testIPEsWithSameNameHaveUniqueHandles_set() {
+ runTest("ipes with same name have unique handles - set");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ String handle1 = "*Set.aj[C1~method?field-set(int C1.x)";
+ assertNotNull("expected to find node with handle " + handle1
+ + ", but did not",top.getElement(handle1));
+
+ String handle2 = "*Set.aj[C1~method?field-set(int C1.x)!2";
+ assertNotNull("expected to find node with handle " + handle2
+ + ", but did not",top.getElement(handle2));
+ }
//---------- following tests ensure we produce the same handles as jdt -----//
//---------- (apart from the prefix)
diff --git a/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml b/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml
index ba52be4d3..3d0172e0a 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml
+++ b/tests/src/org/aspectj/systemtest/ajc153/jdtlikehandleprovider.xml
@@ -208,4 +208,24 @@
<compile files="Java5Class.java" options="-emacssym -1.5"/>
</ajc-test>
+ <ajc-test dir="features153/jdtlikehandleprovider" title="ipes with same name have unique handles - method-call">
+ <compile files="TwoMethodCalls.aj" options="-emacssym"/>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="ipes with different names do not have counter - method-call">
+ <compile files="TwoDiffMethodCalls.aj" options="-emacssym"/>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="ipes with same name have unique handles - handler">
+ <compile files="Handler.aj" options="-emacssym"/>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="ipes with same name have unique handles - get">
+ <compile files="Get.aj" options="-emacssym"/>
+ </ajc-test>
+
+ <ajc-test dir="features153/jdtlikehandleprovider" title="ipes with same name have unique handles - set">
+ <compile files="Set.aj" options="-emacssym"/>
+ </ajc-test>
+
</suite>
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
index 84145e176..43c4bf3a5 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
@@ -1494,7 +1494,12 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
warnings.isEmpty());
alter("PR152589","inc1");
build("PR152589");
- checkWasFullBuild();
+ if (AsmManager.getDefault().getHandleProvider().dependsOnLocation())
+ checkWasFullBuild(); // the line number has changed... but nothing structural about the code
+ else
+ checkWasntFullBuild(); // the line number has changed... but nothing structural about the code
+
+// checkWasFullBuild();
warnings = MyTaskListManager.getWarningMessages();
assertTrue("There should be no warnings after adding a whitespace:\n"
+warnings,warnings.isEmpty());
@@ -1698,4 +1703,4 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
return new File(projDir,"bin"+File.separator+filename);
}
-}
+} \ No newline at end of file