summaryrefslogtreecommitdiff
path: root/chapter18/src/test/java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-01-13 15:50:26 -0800
committerCliff Click <cliffc@acm.org>2025-01-15 15:07:30 -0800
commitc3559bb04362b948c390b35cac622ce61f494238 (patch)
tree21fbae485fb7c050c02887219ab38562e286b3fd /chapter18/src/test/java
parent9191219b0f5904458b71e0ae7a6382d4c550d2ca (diff)
downloadSimple-c3559bb04362b948c390b35cac622ce61f494238.tar.gz
Simple-c3559bb04362b948c390b35cac622ce61f494238.zip
Missing constant test
Diffstat (limited to 'chapter18/src/test/java')
-rw-r--r--chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java20
-rw-r--r--chapter18/src/test/java/com/seaofnodes/simple/Eval2.java2
2 files changed, 20 insertions, 2 deletions
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java
index 64c07cf0..0e92c8c0 100644
--- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java
+++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java
@@ -13,9 +13,9 @@ public class Chapter18Test {
"""
return 0;
""");
- code.parse().opto().typeCheck().GCM();
+ code.parse().opto().typeCheck().GCM().localSched();
assertEquals("return 0;", code._stop.toString());
- assertEquals("0", Eval2.eval(code, 1));
+ assertEquals("0", Eval2.eval(code, 2));
}
@Test
@@ -297,4 +297,20 @@ for(;;) {
assertEquals("0", Eval2.eval(code, 0));
}
+ // Inline hidden called more than once
+ @Test
+ public void testInline() {
+ CodeGen code = new CodeGen(
+"""
+{int->int}?! i2i = {int i->return i;};
+{{int->int}->{int->int}}! f2f = {{int->int} f->return f;};
+val o = i2i;
+if (arg) i2i = null;
+if (i2i) return i2i(arg);
+return f2f(o)(1);
+""");
+ code.parse().opto().typeCheck().GCM().localSched();
+ assertEquals("Stop[ return Phi(Region,o( arg),o( 1)); return Parm_i(o,int,arg,1); ]", code._stop.toString());
+ assertEquals("1", Eval2.eval(code, 2));
+ }
}
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java b/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java
index 006034e9..913e21e9 100644
--- a/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java
+++ b/chapter18/src/test/java/com/seaofnodes/simple/Eval2.java
@@ -137,6 +137,7 @@ public abstract class Eval2 {
// Evaluate until exit or timeout. Each outer loop step computes
// all data nodes under some new Control.
while( true ) {
+ assert BB!=null;
traceCtrl(BB,trace);
if( trace!=null ) System.out.println(F.p());
@@ -165,6 +166,7 @@ public abstract class Eval2 {
case RegionNode r : break;
default: throw Utils.TODO();
}
+ assert !BB.isDead();
}
}