diff options
Diffstat (limited to 'tests')
10 files changed, 268 insertions, 3 deletions
diff --git a/tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java b/tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java new file mode 100644 index 000000000..0d4ee3e45 --- /dev/null +++ b/tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java @@ -0,0 +1,71 @@ +package test; + +/** + * Understands . . . + * + * @author Randy Stearns + */ +public class BooleanUnitTest { + + public static void main(String[] args) { + new BooleanUnitTest().test1(); + } + + public void test1() { + assertEquals("1a WRONG!", false, invert1a()); + assertEquals("1b WRONG!", true, invert1b()); + assertEquals("2 WRONG!", false, invert2()); + assertEquals("3 WRONG!", true, invert3()); + assertEquals("4 WRONG!", true, invert4()); + assertEquals("5 WRONG!", false, invert5()); + } + + private void assertEquals(String msg, boolean a, boolean b) { + if (a != b) { + throw new RuntimeException(msg); + } + } + + private boolean invert1a() { + return ! true; + } + + private boolean invert1b() { + return ! false; + } + + private boolean invert2() { + boolean ret = false; + try { + ret = ! isTrue(); + } + catch (RuntimeException t) { + LoggingAspect.aspectOf().ajc$afterReturning$test_LoggingAspect$1$188fbb36(); + throw t; + } + LoggingAspect.aspectOf().ajc$afterReturning$test_LoggingAspect$1$188fbb36(); + return ret; + } + + private boolean invert3() { + return ! isFalse(); + } + + private boolean invert4() { + boolean temp = isFalse(); + return ! temp; + } + + private boolean invert5() { + boolean temp = isTrue(); + return ! temp; + } + + private boolean isTrue() { + return true; + } + + private boolean isFalse() { + return false; + } +} diff --git a/tests/bugs152/pr148007/purejava/test/LoggingAspect.java b/tests/bugs152/pr148007/purejava/test/LoggingAspect.java new file mode 100644 index 000000000..4b265eb6d --- /dev/null +++ b/tests/bugs152/pr148007/purejava/test/LoggingAspect.java @@ -0,0 +1,32 @@ +package test; + +import org.aspectj.lang.NoAspectBoundException; + +public class LoggingAspect { + + private static LoggingAspect ajc$perSingletonInstance; + private static Throwable ajc$initFailureCause; + + static { + try { + ajc$postClinit(); + } + catch (Throwable t) { + ajc$initFailureCause = t; + } + } + + public static LoggingAspect aspectOf() { + if (ajc$perSingletonInstance == null) { + throw new NoAspectBoundException("test_LoggingAspect",ajc$initFailureCause); + } + return ajc$perSingletonInstance; + } + + public void ajc$afterReturning$test_LoggingAspect$1$188fbb36() { + } + + private static void ajc$postClinit() { + ajc$perSingletonInstance = new LoggingAspect(); + } +} diff --git a/tests/bugs152/pr148007/test/BooleanUnitTest.java b/tests/bugs152/pr148007/test/BooleanUnitTest.java new file mode 100644 index 000000000..a3b64e715 --- /dev/null +++ b/tests/bugs152/pr148007/test/BooleanUnitTest.java @@ -0,0 +1,62 @@ +package test; + +/** + * Understands . . . + * + * @author Randy Stearns + */ +public class BooleanUnitTest { + + public static void main(String[] args) { + new BooleanUnitTest().test1(); + } + + public void test1() { + assertEquals("1a WRONG!", false, invert1a()); + assertEquals("1b WRONG!", true, invert1b()); + assertEquals("2 WRONG!", false, invert2()); + assertEquals("3 WRONG!", true, invert3()); + assertEquals("4 WRONG!", true, invert4()); + assertEquals("5 WRONG!", false, invert5()); + } + + private void assertEquals(String msg, boolean a, boolean b) { + if (a != b) { + throw new RuntimeException(msg); + } + } + + private boolean invert1a() { + return ! true; + } + + private boolean invert1b() { + return ! false; + } + + private boolean invert2() { + return ! isTrue(); + } + + private boolean invert3() { + return ! isFalse(); + } + + private boolean invert4() { + boolean temp = isFalse(); + return ! temp; + } + + private boolean invert5() { + boolean temp = isTrue(); + return ! temp; + } + + private boolean isTrue() { + return true; + } + + private boolean isFalse() { + return false; + } +} diff --git a/tests/bugs152/pr148007/test/LoggingAspect.aj b/tests/bugs152/pr148007/test/LoggingAspect.aj new file mode 100644 index 000000000..ad52be82d --- /dev/null +++ b/tests/bugs152/pr148007/test/LoggingAspect.aj @@ -0,0 +1,17 @@ +package test; + +public aspect LoggingAspect { + + pointcut logPointcut() : + execution (* *(..)) + && within (test..*) + && !within(LoggingAspect); + + before() : logPointcut() { + System.out.println("entering"); + } + + after() : logPointcut() { + System.out.println("exiting"); + } +} diff --git a/tests/bugs152/pr148007/test/TestServlet.java b/tests/bugs152/pr148007/test/TestServlet.java new file mode 100644 index 000000000..b7fc8b408 --- /dev/null +++ b/tests/bugs152/pr148007/test/TestServlet.java @@ -0,0 +1,69 @@ +package test; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * Hello world! + */ +public class TestServlet extends HttpServlet { + + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + booleanTest(response); + } + + private void booleanTest(HttpServletResponse response) throws ServletException { + PrintWriter out = null; + try { + out = response.getWriter(); + } catch (IOException ioe) { + throw new ServletException("Could not get writer."); + } + + out.println("Test 1a. Should be false. Was: " + invert1a()); + out.println("Test 1b. Should be true. Was: " + invert1b()); + out.println("Test 2. Should be false. Was: " + invert2()); + out.println("Test 3. Should be true. Was: " + invert3()); + out.println("Test 4. Should be true. Was: " + invert4()); + out.println("Test 5. Should be false. Was: " + invert5()); + } + + private boolean invert1a() { + return ! true; + } + + private boolean invert1b() { + return ! false; + } + + private Boolean invert2() { + return new Boolean(! isTrue()); + } + + private Boolean invert3() { + return new Boolean(! isFalse()); + } + + private boolean invert4() { + boolean temp = isFalse(); + return ! temp; + } + + private Boolean invert5() { + boolean temp = isTrue(); + return new Boolean(! temp); + } + + private boolean isTrue() { + return true; + } + + private boolean isFalse() { + return false; + } +} diff --git a/tests/features152/synchronization/transformed/expected/C.m.txt b/tests/features152/synchronization/transformed/expected/C.m.txt index 7f5a34cdc..70270b463 100644 --- a/tests/features152/synchronization/transformed/expected/C.m.txt +++ b/tests/features152/synchronization/transformed/expected/C.m.txt @@ -20,4 +20,5 @@ L0: INVOKESTATIC Four.aspectOf ()LFour; INVOKEVIRTUAL Four.ajc$afterReturning$Four$1$c2776aed ()V RETURN + RETURN end public void m() diff --git a/tests/features152/synchronization/transformed/expected/C.m3.txt b/tests/features152/synchronization/transformed/expected/C.m3.txt index f1157285e..f6406ff45 100644 --- a/tests/features152/synchronization/transformed/expected/C.m3.txt +++ b/tests/features152/synchronization/transformed/expected/C.m3.txt @@ -20,4 +20,5 @@ L0: INVOKESTATIC Three.aspectOf ()LThree; INVOKEVIRTUAL Three.ajc$afterReturning$Three$1$3f09355c ()V RETURN + RETURN end public void m3() diff --git a/tests/features152/synchronization/transformed/expected/C.m33.txt b/tests/features152/synchronization/transformed/expected/C.m33.txt index 86b78ffb3..c96a8e2be 100644 --- a/tests/features152/synchronization/transformed/expected/C.m33.txt +++ b/tests/features152/synchronization/transformed/expected/C.m33.txt @@ -17,8 +17,9 @@ | MONITOREXIT finally -> E1 ATHROW - L0: GOTO L1 (line 33) - L1: INVOKESTATIC Three.aspectOf ()LThree; + L0: NOP (line 33) + INVOKESTATIC Three.aspectOf ()LThree; INVOKEVIRTUAL Three.ajc$afterReturning$Three$3$b48e4ae1 ()V RETURN + RETURN end public void m33() diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java index 22c02cd03..79a3dc233 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -99,6 +99,8 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testSuperCallsInAtAspectJAdvice_pr139749() { runTest("Super calls in @AspectJ advice");} public void testNoClassCastExceptionWithPerThis_pr138286() { runTest("No ClassCastException with perThis");} public void testGenericAspectHierarchyWithBounds_pr147845() { runTest("Generic abstract aspect hierarchy with bounds"); } + public void testJRockitBooleanReturn_pr148007() { runTest("jrockit boolean fun");} + public void testJRockitBooleanReturn2_pr148007() { runTest("jrockit boolean fun (no aspects)");} public void testDeclareAtMethodRelationship_pr143924() { //AsmManager.setReporting("c:/debug.txt",true,true,true,true); diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index 370d24ad9..da553bad9 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -729,5 +729,14 @@ </stderr> </run> </ajc-test> - + + <ajc-test dir="bugs152/pr148007" title="jrockit boolean fun"> + <compile files="test/BooleanUnitTest.java, test/LoggingAspect.aj"/> + <run class="test.BooleanUnitTest"/> + </ajc-test> + + <ajc-test dir="bugs152/pr148007/purejava" title="jrockit boolean fun (no aspects)"> + <compile files="test/BooleanUnitTest.java, test/LoggingAspect.java" options="-inlineJSR"/> + <run class="test.BooleanUnitTest"/> + </ajc-test> </suite>
\ No newline at end of file |