diff options
author | aclement <aclement> | 2004-10-21 12:55:49 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-10-21 12:55:49 +0000 |
commit | a303a09bbdbee8ce39e2ba00a3a33e54df92c24f (patch) | |
tree | 005efce0d7bf355351063ab726471c412e5e5200 /tests | |
parent | d3108e86e0eee2d180bcb5ec91e87f9559b88329 (diff) | |
download | aspectj-a303a09bbdbee8ce39e2ba00a3a33e54df92c24f.tar.gz aspectj-a303a09bbdbee8ce39e2ba00a3a33e54df92c24f.zip |
Fix for Bugzilla Bug 74952: before,after !(cflow(within(Trace*))) prints nothing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs/WhatsGoingOn.java | 151 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java | 22 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml | 5 |
3 files changed, 178 insertions, 0 deletions
diff --git a/tests/bugs/WhatsGoingOn.java b/tests/bugs/WhatsGoingOn.java new file mode 100644 index 000000000..1838bc4c3 --- /dev/null +++ b/tests/bugs/WhatsGoingOn.java @@ -0,0 +1,151 @@ +public class WhatsGoingOn { + static public void main (String [] args) { } +} + +aspect TraceClass { + static private int level = 0; + + static private void offset() { + for (int i = 0; i < level; ++i) System.err.print(" "); + } + + pointcut pc() : + !cflow(within(Trace*)) +// !(within(Trace*) || cflowbelow(within(Trace*))) + ; + before () : pc() { + offset(); + System.err.println("-> " + thisJoinPoint); + ++level; + } + after () : pc() { + --level; + offset(); + System.err.println("<- " + thisJoinPoint); + } +} + +aspect TraceTrace { + + static private int level = 0; + + static private void offset() { + for (int i = 0; i < level; ++i) System.err.print(" "); + } + + pointcut pc() : within(TraceClass); + before () : pc() { + offset(); + System.err.println("=> " + thisJoinPoint); + ++level; + } + after () : pc() { + --level; + offset(); + System.err.println("<= " + thisJoinPoint); + } +} + +//Expected output: +//"=> staticinitialization(TraceClass.<clinit>)\n"+ +//" => set(int TraceClass.level)\n"+ +//" <= set(int TraceClass.level)\n"+ +//" => preinitialization(TraceClass())\n"+ +//" <= preinitialization(TraceClass())\n"+ +//" => initialization(TraceClass())\n"+ +//" => execution(TraceClass())\n"+ +//" <= execution(TraceClass())\n"+ +//" <= initialization(TraceClass())\n"+ +//"<= staticinitialization(TraceClass.<clinit>)\n"+ +//"=> execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+ +//" => call(void TraceClass.offset())\n"+ +//" => execution(void TraceClass.offset())\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" <= execution(void TraceClass.offset())\n"+ +//" <= call(void TraceClass.offset())\n"+ +//" => get(PrintStream java.lang.System.err)\n"+ +//" <= get(PrintStream java.lang.System.err)\n"+ +//" => call(java.lang.StringBuffer(String))\n"+ +//" <= call(java.lang.StringBuffer(String))\n"+ +//" => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" => call(String java.lang.StringBuffer.toString())\n"+ +//" <= call(String java.lang.StringBuffer.toString())\n"+ +//" => call(void java.io.PrintStream.println(String))\n"+ +//"-> staticinitialization(WhatsGoingOn.<clinit>)\n"+ +//" <= call(void java.io.PrintStream.println(String))\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" => set(int TraceClass.level)\n"+ +//" <= set(int TraceClass.level)\n"+ +//"<= execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+ +//"=> execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" => set(int TraceClass.level)\n"+ +//" <= set(int TraceClass.level)\n"+ +//" => call(void TraceClass.offset())\n"+ +//" => execution(void TraceClass.offset())\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" <= execution(void TraceClass.offset())\n"+ +//" <= call(void TraceClass.offset())\n"+ +//" => get(PrintStream java.lang.System.err)\n"+ +//" <= get(PrintStream java.lang.System.err)\n"+ +//" => call(java.lang.StringBuffer(String))\n"+ +//" <= call(java.lang.StringBuffer(String))\n"+ +//" => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" => call(String java.lang.StringBuffer.toString())\n"+ +//" <= call(String java.lang.StringBuffer.toString())\n"+ +//" => call(void java.io.PrintStream.println(String))\n"+ +//"<- staticinitialization(WhatsGoingOn.<clinit>)\n"+ +//" <= call(void java.io.PrintStream.println(String))\n"+ +//"<= execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n"+ +//"=> execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+ +//" => call(void TraceClass.offset())\n"+ +//" => execution(void TraceClass.offset())\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" <= execution(void TraceClass.offset())\n"+ +//" <= call(void TraceClass.offset())\n"+ +//" => get(PrintStream java.lang.System.err)\n"+ +//" <= get(PrintStream java.lang.System.err)\n"+ +//" => call(java.lang.StringBuffer(String))\n"+ +//" <= call(java.lang.StringBuffer(String))\n"+ +//" => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" => call(String java.lang.StringBuffer.toString())\n"+ +//" <= call(String java.lang.StringBuffer.toString())\n"+ +//" => call(void java.io.PrintStream.println(String))\n"+ +//"-> execution(void WhatsGoingOn.main(String[]))\n"+ +//" <= call(void java.io.PrintStream.println(String))\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" => set(int TraceClass.level)\n"+ +//" <= set(int TraceClass.level)\n"+ +//"<= execution(ADVICE: void TraceClass.ajc$before$TraceClass$1$346234(JoinPoint))\n"+ +//"=> execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" => set(int TraceClass.level)\n"+ +//" <= set(int TraceClass.level)\n"+ +//" => call(void TraceClass.offset())\n"+ +//" => execution(void TraceClass.offset())\n"+ +//" => get(int TraceClass.level)\n"+ +//" <= get(int TraceClass.level)\n"+ +//" <= execution(void TraceClass.offset())\n"+ +//" <= call(void TraceClass.offset())\n"+ +//" => get(PrintStream java.lang.System.err)\n"+ +//" <= get(PrintStream java.lang.System.err)\n"+ +//" => call(java.lang.StringBuffer(String))\n"+ +//" <= call(java.lang.StringBuffer(String))\n"+ +//" => call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" <= call(StringBuffer java.lang.StringBuffer.append(Object))\n"+ +//" => call(String java.lang.StringBuffer.toString())\n"+ +//" <= call(String java.lang.StringBuffer.toString())\n"+ +//" => call(void java.io.PrintStream.println(String))\n"+ +//"<- execution(void WhatsGoingOn.main(String[]))\n"+ +//" <= call(void java.io.PrintStream.println(String))\n"+ +//"<= execution(ADVICE: void TraceClass.ajc$after$TraceClass$2$346234(JoinPoint))\n");
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java index 6e86caacc..1926ea38e 100644 --- a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java @@ -20,6 +20,9 @@ import org.aspectj.testing.XMLBasedAjcTestCase; public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + + public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Ajc121Tests.class); } @@ -337,5 +340,24 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void test064() { runTest("Anonymous classes unaware of introductions into abstract classes"); } + + private int countLines(String s) { + int lines = 0; + int idx = 0; + while (s.indexOf("\n",idx)!=-1) { + lines++; + idx = s.indexOf("\n",idx)+1; + } + return lines; + } + + public void test065() { + runTest("before,after not (cflow(within(Trace*))) prints nothing"); + String s = getLastRunResult().getStdErr(); + int lines = countLines(s); + assertTrue("The actual output does not match the expected output. Expected 102 lines but got "+ + lines+" lines. Actual output =\n"+s,lines==102); + // IF YOU WANT TO SEE THE EXPECTED OUTPUT, LOOK IN THE TEST PROGRAM bugs/WhatsGoingOn.java + } }
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml index 2ec496b35..77d52f3dc 100644 --- a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml @@ -495,3 +495,8 @@ <compile files="ConcreteClassA.java"/> <run class="ConcreteClassA"/> </ajc-test> + + <ajc-test dir="bugs" pr="74952" title="before,after not (cflow(within(Trace*))) prints nothing"> + <compile files="WhatsGoingOn.java"/> + <run class="WhatsGoingOn"/> + </ajc-test> |