diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-19 11:48:37 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-19 11:48:37 -0700 |
| commit | 3617495d8efbcce23bbc9f1754c7d27d34d30a52 (patch) | |
| tree | 65684567f224af8018626dc52d529e206af1a659 /chapter25/src/test/java/com/seaofnodes | |
| parent | e7eb2db06d1b9c529f94f2da3a087c83c0498e05 (diff) | |
| download | Simple-3617495d8efbcce23bbc9f1754c7d27d34d30a52.tar.gz Simple-3617495d8efbcce23bbc9f1754c7d27d34d30a52.zip | |
Fix a missed int-widening around recursion
Diffstat (limited to 'chapter25/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter25/src/test/java/com/seaofnodes/simple/Chapter24Test.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter24Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter24Test.java index 2f125ed0..2bc2ce7f 100644 --- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter24Test.java +++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter24Test.java @@ -17,6 +17,20 @@ import org.junit.Test; import static org.junit.Assert.*; public class Chapter24Test { + @Test public void testRecursiveWidening() { + String[] srcs = { + // Parm(x) must widen even though the recursive result is constant. + "val f = { int x, int limit -> x >= limit ? 0 : f(x+1,limit); }; return f(0,arg);", + // The growing result has its own cycle, which never crosses Parm(x). + "val f = { int x -> x <= 0 ? 0 : f(x-1)+1; }; return f(3);" + }; + for( int i=0; i<srcs.length; i++ ) + for( long seed : new long[]{0,42,126} ) { + var code = new CodeGen(srcs[i],seed,true).driver(CodeGen.Phase.LocalSched); + assertEquals(i==0 ? "0" : "3",Eval2.eval(code,3)); + } + } + @Test public void testColdLoopSelfConflict() { com.seaofnodes.simple.codegen.RegAllocTestSupport.coldLoopSelfConflict(); } @Test public void testPrintingDeadFunction() throws Exception { |
