summaryrefslogtreecommitdiff
path: root/chapter25/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'chapter25/src/test/java/com')
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java8
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java18
2 files changed, 26 insertions, 0 deletions
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java
index f5e3d752..2677de5e 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java
@@ -83,6 +83,14 @@ public class Chapter25Test {
assertEquals("return 0;",code.print());
}
+ @Test
+ public void testFuzzerBadLCA() {
+ new CodeGen("""
+ int v0=arg;
+ if(v0&&--v0?0:arg) {}
+ """).driver(CodeGen.Phase.LocalSched);
+ }
+
@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/fuzzer/Fuzzer.java b/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java
index 37fa03a6..223515f8 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java
@@ -163,6 +163,24 @@ public class Fuzzer {
check(sb.toString(), valid, seed);
}
+ /**
+ * Run one seed as a regression test. Unlike the exploratory fuzzer path,
+ * this deliberately does not reduce on failure; old bad seeds should fail
+ * fast with the seed visible in the JUnit assertion.
+ */
+ public void fuzzPeepsRegression(long seed) {
+ var rand = new Random(seed);
+ var sb = new StringBuilder();
+ var valid = new ScriptGenerator(rand, sb, true).genProgram();
+ try {
+ runCheck(sb.toString(), valid);
+ } catch( Throwable e ) {
+ AssertionError ae = new AssertionError("Fuzzer regression seed failed: "+seed);
+ ae.initCause(e);
+ throw ae;
+ }
+ }
+
/**
* Check that no exceptions happened.