summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/Chapter18Test.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2025-06-13 15:42:08 -0700
committerCliff Click <cliffc@acm.org>2026-10-24 15:56:44 -0700
commitb59f51486393b2fae7b0015bc5099c5514c7335a (patch)
tree709c7ee19d0fb2467ecb353960f74722f3fd916d /src/test/java/com/seaofnodes/simple/Chapter18Test.java
parent89dd0a79da85b2c7102b7c8918a1466e6238fe94 (diff)
downloadSimple-linear-chapter24b.tar.gz
Simple-linear-chapter24b.zip
Chapter 24b: SCCP Across Functionslinear-chapter24b
Co-authored-by: Tamás Hadházy <85063808+Hels15@users.noreply.github.com> Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Jun Kawasaki <jun784@gmail.com> Co-authored-by: Hadházy Tamás <helsgithub15@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter18Test.java')
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter18Test.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/src/test/java/com/seaofnodes/simple/Chapter18Test.java
index e5dd259b..b6a0ab57 100644
--- a/src/test/java/com/seaofnodes/simple/Chapter18Test.java
+++ b/src/test/java/com/seaofnodes/simple/Chapter18Test.java
@@ -406,8 +406,7 @@ return g();
}
- // Local SCCP cannot infer this recursive return type. The next chapter
- // solves across calls and checks the same program's execution results.
+ // Mutual recursion: check results, independent of how much gets inlined.
@Test
public void testFcnMutRec() {
CodeGen code = new CodeGen(
@@ -416,8 +415,11 @@ val is_even = { int x -> x ? is_odd (x-1) : true ; };
val is_odd = { int x -> x ? is_even(x-1) : false; };
return is_even(arg);
""");
- try { code.driver(CodeGen.Phase.TypeCheck); fail(); }
- catch( Parser.ParseException e ) { assertEquals("No defined return type",e.getMessage()); }
+ code.driver(CodeGen.Phase.FinalizeIR);
+ assertEquals("1", Eval2.eval(code, 0));
+ assertEquals("0", Eval2.eval(code, 1));
+ assertEquals("1", Eval2.eval(code, 2));
+ assertEquals("0", Eval2.eval(code, 3));
}
// Forward ref to 'x' means that