From 0a669bf5fa11a63516ea8f5316b0079c2eee4bde Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 28 Oct 2023 20:35:29 -0700 Subject: Update README Add true/false --- .../test/java/com/seaofnodes/simple/Chapter05Test.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'chapter05/src/test/java') diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java index e59d1dbd..8f09620e 100644 --- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java +++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java @@ -62,7 +62,14 @@ return c; StopNode ret = parser.parse(); assertEquals("return (Phi(Region31,(arg+1),(arg+3))+Phi(Region31,((arg*2)+3),(arg+2)));", ret.toString()); } - + + @Test + public void testChapter5Merge3() { + Parser parser = new Parser("int a=1; if( arg==1 ) if( arg==2 ) a=2; else a=3; else if( arg==3 ) a=4; else a=5; return a; #showGraph;", TypeInteger.BOT); + StopNode stop = parser.parse(); + assertEquals("return Phi(Region33,Phi(Region21,2,3),Phi(Region31,4,5));", stop.toString()); + } + @Test public void testChapter5HalfDef() { try { @@ -82,6 +89,12 @@ return c; assertEquals("Undefined name 'b'",e.getMessage()); } } + + @Test + public void testChapter5True() { + StopNode stop = new Parser("return true;").parse(); + assertEquals("return 1;",stop.toString()); + } @Test public void testChapter4Peephole() { -- cgit v1.2.3