diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2012-06-05 16:03:48 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2012-06-05 16:03:48 +0000 |
commit | 12d5a5f3ccaec717942009a56089eaf34d4783d7 (patch) | |
tree | 6ce47287cbde72c94bc37ebb55bc57e047535a1c /src | |
parent | 4ef16d3ab2ab50a9d04623018187d716f6cb434e (diff) | |
download | javassist-12d5a5f3ccaec717942009a56089eaf34d4783d7.tar.gz javassist-12d5a5f3ccaec717942009a56089eaf34d4783d7.zip |
fixed JASSIST-168
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@632 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test/javassist/bytecode/analysis/DomTreeTest.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/test/javassist/bytecode/analysis/DomTreeTest.java b/src/test/test/javassist/bytecode/analysis/DomTreeTest.java index dd348d01..4e277e8f 100644 --- a/src/test/test/javassist/bytecode/analysis/DomTreeTest.java +++ b/src/test/test/javassist/bytecode/analysis/DomTreeTest.java @@ -36,10 +36,12 @@ public class DomTreeTest extends TestCase { } private void testBlock(Block b, int[] incoming, int[] outgoing) { + assertEquals(incoming.length, b.incomings()); int i = 0; for (int index: incoming) assertEquals(index, b.incoming(i++).position()); i = 0; + assertEquals(outgoing.length, b.exits()); for (int index: outgoing) assertEquals(index, b.exit(i++).position()); } @@ -56,4 +58,35 @@ public class DomTreeTest extends TestCase { k = 3 ; } } + + public void testDomtree2() throws Exception { + ControlFlow cf = new ControlFlow(pool.get(DomTreeTest.class.getName()).getDeclaredMethod("test2")); + Block[] blocks = cf.basicBlocks(); + // for (int i = 0; i < blocks.length; i++) + // System.out.println(i + ": " + blocks[i]); + testBlock(blocks[0], new int[] { 7 }, new int[] { 14, 7 } ); + testBlock(blocks[1], new int[] { 0 }, new int[] { 0, 12 } ); + testBlock(blocks[2], new int[] { 7 }, new int[] {}); + testBlock(blocks[3], new int[] { 0 }, new int[] {}); + + Node[] dom = cf.dominatorTree(); + assertNull(dom[0].parent()); + assertEquals(0, dom[1].parent().block().position()); + assertEquals(7, dom[2].parent().block().position()); + assertEquals(0, dom[3].parent().block().position()); + + Node[] pdom = cf.postDominatorTree(); + assertNull(pdom[0].parent()); + assertNull(pdom[1].parent()); + assertNull(pdom[2].parent()); + assertNull(pdom[3].parent()); + } + + public int test2(int i){ + while (i-- > 0) + if (i == 3) + return 1; + + return i + 3; + } } |