summaryrefslogtreecommitdiff
path: root/chapter12/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'chapter12/src/test/java')
-rw-r--r--chapter12/src/test/java/com/seaofnodes/simple/Chapter11Test.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/chapter12/src/test/java/com/seaofnodes/simple/Chapter11Test.java b/chapter12/src/test/java/com/seaofnodes/simple/Chapter11Test.java
index 6c1f7938..dfb1786b 100644
--- a/chapter12/src/test/java/com/seaofnodes/simple/Chapter11Test.java
+++ b/chapter12/src/test/java/com/seaofnodes/simple/Chapter11Test.java
@@ -511,4 +511,21 @@ return v;
StopNode stop = parser.parse(false).iterate(true);
//assertEquals("return new S;", stop.toString());
}
+
+ @Test
+ public void testSplit() {
+ Parser parser = new Parser(
+ """
+struct S { int f; }
+S s = new S;
+if( arg==0 ) s.f = 1;
+else if (arg == 1) s.f = 1;
+return s.f;
+""");
+ StopNode stop = parser.parse(false).iterate(true);
+ assertEquals("return Phi(Region35,1,Phi(Region33,1,0));", stop.toString());
+ assertEquals(1L, Evaluator.evaluate(stop, 0));
+ assertEquals(1L, Evaluator.evaluate(stop, 1));
+ assertEquals(0L, Evaluator.evaluate(stop, 2));
+ }
}