summaryrefslogtreecommitdiff
path: root/chapter13/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'chapter13/src/test')
-rw-r--r--chapter13/src/test/java/com/seaofnodes/simple/Chapter11Test.java17
-rw-r--r--chapter13/src/test/java/com/seaofnodes/simple/Chapter13Test.java2
2 files changed, 18 insertions, 1 deletions
diff --git a/chapter13/src/test/java/com/seaofnodes/simple/Chapter11Test.java b/chapter13/src/test/java/com/seaofnodes/simple/Chapter11Test.java
index e367184c..a47bf471 100644
--- a/chapter13/src/test/java/com/seaofnodes/simple/Chapter11Test.java
+++ b/chapter13/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(Region37,1,Phi(Region35,1,0));", stop.toString());
+ assertEquals(1L, Evaluator.evaluate(stop, 0));
+ assertEquals(1L, Evaluator.evaluate(stop, 1));
+ assertEquals(0L, Evaluator.evaluate(stop, 2));
+ }
}
diff --git a/chapter13/src/test/java/com/seaofnodes/simple/Chapter13Test.java b/chapter13/src/test/java/com/seaofnodes/simple/Chapter13Test.java
index f7d4d5a8..a58ad583 100644
--- a/chapter13/src/test/java/com/seaofnodes/simple/Chapter13Test.java
+++ b/chapter13/src/test/java/com/seaofnodes/simple/Chapter13Test.java
@@ -35,7 +35,7 @@ while( arg ) {
return head.next.i;
""");
try { parser.parse(true).iterate(true); fail(); }
- catch( Exception e ) { assertEquals("Might be null accessing 'i'",e.getMessage()); }
+ catch( Exception e ) { assertEquals("Might be null accessing 'next'",e.getMessage()); }
}
@Test