diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/CflowBelowTest.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/CflowBelowTest.java')
-rw-r--r-- | tests/new/CflowBelowTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/new/CflowBelowTest.java b/tests/new/CflowBelowTest.java new file mode 100644 index 000000000..f6c7e07a7 --- /dev/null +++ b/tests/new/CflowBelowTest.java @@ -0,0 +1,44 @@ +import org.aspectj.testing.Tester; + +import java.util.*; + +/** + * Inspired by aspect sandbox and submitted by Chris Dutchyn + */ +public class CflowBelowTest { + static final String[] expectedSteps = new String[] { + "Num.fact(4) within Num.fact(5) within another Num.fact(6)", + "Num.fact(3) within Num.fact(4) within another Num.fact(5)", + "Num.fact(2) within Num.fact(3) within another Num.fact(4)", + "Num.fact(1) within Num.fact(2) within another Num.fact(3)", + }; + + static List steps = new ArrayList(); + + static public void main( String[] args ) { + Tester.checkEqual(new Num().fact(6), 720); + + Tester.checkEqual(steps.toArray(), expectedSteps, "steps"); + } +} + + +class Num { + int fact(int x) { + if (x == 1) + return 1; + return x * fact(x - 1); + } +} + +// check that cflows of nested calls obtain correct parameters +aspect CflowBelow01 { + before (int x1, int x2, int x3) : + call(int Num.fact(int)) && args(x1) + && cflowbelow(call(int Num.fact(int)) && args(x2) + && cflowbelow(call(int Num.fact(int)) && args(x3))) { + CflowBelowTest.steps.add("Num.fact(" + x1 + + ") within Num.fact(" + x2 + + ") within another Num.fact(" + x3 + ")"); + } +} |