summaryrefslogtreecommitdiff
path: root/chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-11-15 16:11:39 -0800
committerCliff Click <cliffc@acm.org>2026-11-15 16:11:39 -0800
commit9fe7c6f9697b5bbf3041261fdc60040e75cc674f (patch)
treed92a8ff20ed984938d90ad8917b4d67fba9fb745 /chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java
parentf0a6c6757a795b8e186de0076836a87acef59fa7 (diff)
downloadSimple-ch32.tar.gz
Simple-ch32.zip
Split off chapter 31ch32
Ch 32 will be focused on compiler performance issues.
Diffstat (limited to 'chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java')
-rw-r--r--chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java b/chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java
new file mode 100644
index 00000000..e0424573
--- /dev/null
+++ b/chapter32/src/test/java/com/seaofnodes/simple/Chapter28bTest.java
@@ -0,0 +1,29 @@
+package com.seaofnodes.simple;
+
+import com.seaofnodes.simple.codegen.CodeGen;
+import org.junit.Ignore;
+import org.junit.Test;
+//
+import static org.junit.Assert.*;
+
+public class Chapter28bTest {
+
+ @Ignore
+ @Test
+ public void testJig() {
+ String src = """
+struct C {
+ int x;
+ new C = { int n ->
+ while(n--)
+ if(n) x=1;
+ };
+};
+return new C(arg).x;
+""";
+ CodeGen code = new CodeGen(src).driver(CodeGen.Phase.TypeCheck);
+ assertEquals("Stop[ return Phi(Loop,0,Phi(Region,1,Phi_x)); return MEM[ 2:___ 3:.x=Phi(Loop,0,Phi(Region,1,Phi_x));]; return MEM[ 2:___ 3:.x=0;]; return Test.C; ]", code.print());
+ assertEquals("1",Eval2.eval(code,3));
+ }
+
+}