From: aclement Date: Fri, 22 Sep 2006 14:57:29 +0000 (+0000) Subject: tests for 151772, 125981: incorrect scope for dec soft reporting X-Git-Tag: BEFORE_133532~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aefa777dfd64a8a90e2730ff442ebf99f832162f;p=aspectj.git tests for 151772, 125981: incorrect scope for dec soft reporting --- diff --git a/tests/bugs153/pr125981/SampleTest.java b/tests/bugs153/pr125981/SampleTest.java new file mode 100644 index 000000000..3712281ce --- /dev/null +++ b/tests/bugs153/pr125981/SampleTest.java @@ -0,0 +1,28 @@ +public class SampleTest { + public interface ByteReadingStrategy { + void readBytes(java.io.InputStream str); + } + + public ByteReadingStrategy byteReadingStrategy; + + private final ByteReadingStrategy offsetBuf = new ByteReadingStrategy() { + public void readBytes(java.io.InputStream str) { + str.read(); + } + }; + + private class NamedByteReadingStrategy { + public void readBytes(java.io.InputStream str) { + str.read(); + } + }; + + public void foo(){} +} + +aspect Soften { + pointcut softenedTests() : + within(SampleTest+) && execution(* *(..)) && !execution(* *(..) throws Exception+); + + declare soft: Exception+: softenedTests(); +} diff --git a/tests/bugs153/pr151772/Softener.aj b/tests/bugs153/pr151772/Softener.aj new file mode 100644 index 000000000..4e021e170 --- /dev/null +++ b/tests/bugs153/pr151772/Softener.aj @@ -0,0 +1,22 @@ +import java.sql.SQLException; + +public aspect Softener { + + // expect this to soften the exception thrown + declare soft: Throwable : execution(* *.run()); +} + +class SoftenInner { + public static void main(String args[]) { + new SoftenInner().foo(); + } + + public void foo() { + new Runnable() { + public void run() { + throw new SQLException("test"); + } + }.run(); + } + +} diff --git a/tests/bugs153/pr151772/Softener2.aj b/tests/bugs153/pr151772/Softener2.aj new file mode 100644 index 000000000..5e8555180 --- /dev/null +++ b/tests/bugs153/pr151772/Softener2.aj @@ -0,0 +1,23 @@ +import java.sql.SQLException; + +public aspect Softener2 { + + // don't expect this to soften the exception thrown + declare soft: Throwable: execution(* SoftenInner.foo()); + +} + +class SoftenInner { + public static void main(String args[]) { + new SoftenInner().foo(); + } + + public void foo() { + new Runnable() { + public void run() { + throw new SQLException("test"); + } + }.run(); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java index 7e6c95f56..0c4e59e8d 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java @@ -95,6 +95,18 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("ensure LineNumberTable correct with generics, for each and continue"); } + public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772() { + runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class"); + } + + public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772_2() { + runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2"); + } + + public void testDeclareSoftAndInnerClasses_pr125981() { + runTest("declare soft and inner classes"); + } + ///////////////////////////////////////// public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class); diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml index 665c73c0f..451bf3a80 100644 --- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml +++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml @@ -447,4 +447,18 @@ + + + + + + + + + + + + + + \ No newline at end of file