diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-11 19:47:39 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-11 19:47:39 -0700 |
| commit | 385db70abc590215a6af0ef53cbb9eefc5405759 (patch) | |
| tree | c7881cc793f7f4f4d19ead2846635d13bbff553f /chapter25/src/test/java/com | |
| parent | cab27a1f349f60eb8ee5bd97ac7fde5cd4547265 (diff) | |
| download | Simple-385db70abc590215a6af0ef53cbb9eefc5405759.tar.gz Simple-385db70abc590215a6af0ef53cbb9eefc5405759.zip | |
More robust on broken inputs
Diffstat (limited to 'chapter25/src/test/java/com')
| -rw-r--r-- | chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java | 11 | ||||
| -rw-r--r-- | chapter25/src/test/java/com/seaofnodes/simple/Eval2.java | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java index a5ef67e8..f5e3d752 100644 --- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java +++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java @@ -72,6 +72,17 @@ public class Chapter25Test { assertEquals("1",Eval2.eval(code,0)); } + @Test + public void testFuzzerUnresolvedNumericLoop() { + CodeGen code = new CodeGen(""" + arg=0; + while(arg+0) + while(-arg) + arg=0; + """).driver(CodeGen.Phase.TypeCheck); + assertEquals("return 0;",code.print()); + } + @Test @Ignore public void testModule0() throws IOException { String MODDIR = "src/test/java/com/seaofnodes/simple/test0"; diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java b/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java index 715c499e..ea4ec326 100644 --- a/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java +++ b/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java @@ -148,7 +148,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; + if( BB==null ) return null; traceCtrl(BB,trace); if( trace!=null ) System.out.println(F.p()); @@ -177,6 +177,7 @@ public abstract class Eval2 { case RegionNode r : break; default: throw Utils.TODO(); } + if( BB==null ) return null; assert !BB.isDead(); } } |
