summaryrefslogtreecommitdiff
path: root/chapter15/src/test/java/com/seaofnodes
diff options
context:
space:
mode:
Diffstat (limited to 'chapter15/src/test/java/com/seaofnodes')
-rw-r--r--chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java b/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java
index 3a379084..6ec7cc1a 100644
--- a/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java
+++ b/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java
@@ -14,8 +14,7 @@ public class Chapter15Test {
@Test
public void testJig() {
- Parser parser = new Parser(
-"""
+ Parser parser = new Parser("""
return 3.14;
""");
StopNode stop = parser.parse().iterate();
@@ -24,6 +23,23 @@ return 3.14;
}
@Test
+ public void testLifetime() {
+ Parser parser = new Parser("""
+u8[] b = new u8[5];
+if (arg) {
+ b[0] = b[0] + 1;
+} else {
+ b[1] = b[1] * 2;
+}
+return b[0] + b[1];
+""");
+ StopNode stop = parser.parse().iterate();
+ assertEquals("return Phi(Region69,1,0);", stop.toString());
+ assertEquals(0L, Evaluator.evaluate(stop, 0));
+ assertEquals(1L, Evaluator.evaluate(stop, 1));
+ }
+
+ @Test
public void testCyclic() {
Parser parser = new Parser(
"""