diff options
author | ehilsdal <ehilsdal> | 2003-11-18 02:43:31 +0000 |
---|---|---|
committer | ehilsdal <ehilsdal> | 2003-11-18 02:43:31 +0000 |
commit | 393f65bdec7a0822eddd55af22a8f7fce9bc58cd (patch) | |
tree | 673ea8f88d6f7554a80df486bee560b2b3a95948 /tests | |
parent | 07cdee49d842cfc761a24c92e611042812719699 (diff) | |
download | aspectj-393f65bdec7a0822eddd55af22a8f7fce9bc58cd.tar.gz aspectj-393f65bdec7a0822eddd55af22a8f7fce9bc58cd.zip |
Work on Bugzilla 42668: effect of an after returning type incompatible with a join point return type
* fix to semantics document to describe correct semantics
* checkin of failing coverage test case for correct semantics
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ajcTestsFailing.xml | 18 | ||||
-rw-r--r-- | tests/bugs/IncompatibleAfterReturningTypeCE.java | 21 | ||||
-rw-r--r-- | tests/ehTests.xml | 10 | ||||
-rw-r--r-- | tests/new/AfterReturningParamMatching.java | 72 |
4 files changed, 90 insertions, 31 deletions
diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index c021e9451..fe3fdc664 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -24,16 +24,6 @@ </ajc-test> <ajc-test dir="bugs" - title="after returning type incompatible with join point return type" - pr="42668" - > - <compile files="IncompatibleAfterReturningTypeCE.java"> - <message kind="error" line="20"/> - <message kind="error" line="22"/> - </compile> - </ajc-test> - - <ajc-test dir="bugs" pr="41888" title="call PCD fails when given subtype of defining type"> <compile files="CallReference.java"/> @@ -143,5 +133,13 @@ files="Main.java"/> <run class="Main"/> </ajc-test> + + <ajc-test dir="new" + pr="42668" + title="after returning with parameter: matching rules"> + <compile files="AfterReturningParamMatching.java" /> + <run class="AfterReturningParamMatching"/> + </ajc-test> + </suite> diff --git a/tests/bugs/IncompatibleAfterReturningTypeCE.java b/tests/bugs/IncompatibleAfterReturningTypeCE.java deleted file mode 100644 index d935d344f..000000000 --- a/tests/bugs/IncompatibleAfterReturningTypeCE.java +++ /dev/null @@ -1,21 +0,0 @@ - -public class IncompatibleAfterReturningTypeCE { - public static void main(String[] args) { - System.setProperty("foo", ""+"".length()); - } -} - -class C { - Integer getInteger() { - return null; - } -} - -/** @testcase PR#42668 after returning type incompatible with join point return type */ -aspect A { - - after () returning (Boolean b) : execution(Integer C.getInteger()) { } // CE 20 incompatible return type from join point - - after () returning (byte b) : call(int String.length()) {} // CE 22 incompatible return type - -}
\ No newline at end of file diff --git a/tests/ehTests.xml b/tests/ehTests.xml new file mode 100644 index 000000000..da5ae284e --- /dev/null +++ b/tests/ehTests.xml @@ -0,0 +1,10 @@ + +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"> + +<suite> + <ajc-test dir="new" pr="42668" + title="after returning with parameter: matching rules"> + <compile files="AfterReturningParamMatching.java" /> + <run class="AfterReturningParamMatching"/> + </ajc-test> +</suite>
\ No newline at end of file diff --git a/tests/new/AfterReturningParamMatching.java b/tests/new/AfterReturningParamMatching.java new file mode 100644 index 000000000..062bfa541 --- /dev/null +++ b/tests/new/AfterReturningParamMatching.java @@ -0,0 +1,72 @@ +import org.aspectj.testing.Tester; + +// this test verifies the matching behaivor for after returning with a typed parameter. + +public class AfterReturningParamMatching { + public static void main(String[] args) { + goBoolean(false); + Tester.checkAndClearEvents(new String[] { "Object" }); + + goByte(1); + Tester.checkAndClearEvents(new String[] { "byte", "int", "long", "Object"}); + + goInt(2); + Tester.checkAndClearEvents(new String[] { "byte", "int", "long", "Object" }); + + goLong(3); + Tester.checkAndClearEvents(new String[] { "byte", "int", "long", "Object" }); + + goObject(new Object()); + Tester.checkAndClearEvents(new String[] { "Object" }); + + goObject(new Integer(4)); + Tester.checkAndClearEvents(new String[] { "Object", "Number", "Integer" }); + + goObject(null); + Tester.checkAndClearEvents(new String[] { "Object" }); + + goNumber(new Long(5)); + Tester.checkAndClearEvents(new String[] { "Object", "Number" }); + + goNumber(new Integer(6)); + Tester.checkAndClearEvents(new String[] { "Object", "Number", "Integer" }); + + goNumber(null); + Tester.checkAndClearEvents(new String[] { "Object", "Number" }); + + goInteger(new Integer(7)); + Tester.checkAndClearEvents(new String[] { "Object", "Number", "Integer" }); + + goInteger(null); + Tester.checkAndClearEvents(new String[] { "Object", "Number", "Integer" }); + + } + static boolean goBoolean(boolean b) { return b; } + static byte goByte(int i) { return (byte) i; } + static int goInt(int i) { return i; } + static long goLong(int i) { return (long) i; } + + static Object goObject(Object o) { return o; } + static Number goNumber(Number o) { return o; } + static Integer goInteger(Integer o) { return o; } +} + +aspect A { + + pointcut methodsInQuestion(): + call(* goBoolean(*)) || + call(* goByte(*)) || + call(* goInt(*)) || + call(* goLong(*)) || + call(* goObject(*)) || + call(* goNumber(*)) || + call(* goInteger(*)); + + after() returning(byte b): methodsInQuestion() { Tester.event("byte"); } + after() returning(int b): methodsInQuestion() { Tester.event("int"); } + after() returning(long b): methodsInQuestion() { Tester.event("long"); } + after() returning(Object b): methodsInQuestion() { Tester.event("Object"); } + after() returning(Number b): methodsInQuestion() { Tester.event("Number"); } + after() returning(Integer b): methodsInQuestion() { Tester.event("Integer"); } + +}
\ No newline at end of file |