summaryrefslogtreecommitdiff
path: root/chapter05/src/test/java/com/seaofnodes
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2023-10-28 20:35:29 -0700
committerDibyendu Majumdar <dibyendumajumdar@users.noreply.github.com>2023-11-01 18:56:50 +0000
commit0a669bf5fa11a63516ea8f5316b0079c2eee4bde (patch)
tree9ce49fae3cf37489413e1b5ec42a2747d60442ef /chapter05/src/test/java/com/seaofnodes
parent2c7e86d4350ed115922e80e6bfc1aef30a881f75 (diff)
downloadSimple-0a669bf5fa11a63516ea8f5316b0079c2eee4bde.tar.gz
Simple-0a669bf5fa11a63516ea8f5316b0079c2eee4bde.zip
Update README
Add true/false
Diffstat (limited to 'chapter05/src/test/java/com/seaofnodes')
-rw-r--r--chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java15
1 files changed, 14 insertions, 1 deletions
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() {