summaryrefslogtreecommitdiff
path: root/chapter25/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'chapter25/src/test/java')
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java65
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java37
2 files changed, 92 insertions, 10 deletions
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java
index 2677de5e..a393a623 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter25Test.java
@@ -21,9 +21,70 @@ public class Chapter25Test {
@Ignore
@Test
public void testJig() {
- String src = "struct _Oan {}; return --arg; arg=++arg;";
+ String src =
+"""
+if(3) arg=arg^arg;
+else return arg;
+u8 v0=arg^--arg;
+if(v0<=1) return 37;
+else {
+ arg=arg;
+ while(3) {
+ arg=v0==++arg;
+ arg=v0;
+ break;
+ }
+}
+arg=arg;
+struct IC95xuj {
+ bool v1;
+ u8 v2;
+ u8 He;
+};
+if(v0<new IC95xuj.He) while(new IC95xuj.He<!new IC95xuj.He) {
+ arg=new IC95xuj.He;
+ if(new IC95xuj.v1) while(new IC95xuj.v1) if(0&&new IC95xuj.v2) continue;
+ else v0=false?new IC95xuj.v2:new IC95xuj.v1&2;
+ else if(new IC95xuj.v2!=3>-++arg*arg) while(false + new IC95xuj.v2) arg=-arg;
+ else continue;
+ v0=new IC95xuj.v2;
+ arg=-new IC95xuj.He;
+ flt v3=-arg||---v0;
+ IC95xuj !v0=new IC95xuj;
+ v3=arg;
+ }
+else {
+ v0=-new IC95xuj.He;
+ v0=---v0/---v0+new IC95xuj.He;
+ return -new IC95xuj.v1|(++arg>arg?new IC95xuj.He:++v0);
+}
+while(-new IC95xuj.He*arg<=--v0||106) return new IC95xuj;
+while(new IC95xuj.v1<new IC95xuj.v2) {
+ if(new IC95xuj.v1||v0) break;
+ else {
+ int arg=new IC95xuj.v1;
+ while(arg<new IC95xuj.v1) {
+ arg=arg+0;
+ while(new IC95xuj.v2+!new IC95xuj.He)
+ continue;
+ arg=0==new IC95xuj;
+ }
+ }
+ v0=1&new IC95xuj.He&new IC95xuj.He^arg;
+ v0=arg||--v0<--new IC95xuj.v2|3?new IC95xuj.v2&-new IC95xuj.v2:new IC95xuj.He;
+ v0=4;
+ break;
+}
+if(new IC95xuj.He) {
+ arg=0;
+ return v0;
+}
+else
+ return new IC95xuj;
+
+""";
CodeGen code = new CodeGen(src).driver(CodeGen.Phase.TypeCheck);
- assertEquals("1",Eval2.eval(code,0));
+ assertEquals("2",Eval2.eval(code,0));
}
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java b/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java
index d67b2065..d7293da1 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java
@@ -13,22 +13,42 @@ import static org.junit.Assert.assertTrue;
*/
public class FuzzerWrap {
- @Ignore
+ private static final long[] REGRESSION_SEEDS = {
+ 375135762521757909L, // bad LCA
+ -148471672577312953L, // bulk mem
+ -5037182906211190034L, // dead Guard control
+ -6359653295501938199L, // monotonicity, escape is dead
+ };
+
+ private static final long[] OPEN_FAILING_SEEDS = {
+ };
+
+
+ @Test public void fuzzPeepsRegression () { fuzzPeepsSeeds( REGRESSION_SEEDS); }
+ @Test @Ignore public void fuzzPeepsOpenFailures() { fuzzPeepsSeeds(OPEN_FAILING_SEEDS); }
+
+ private static void fuzzPeepsSeeds(long... seeds) {
+ var fuzzer = new Fuzzer();
+ for (long seed : seeds)
+ fuzzer.fuzzPeepsRegression(seed);
+ }
+
@Test
- public void fuzzPeeps() {
+ public void fuzzPeepsRandom() {
+ Random R = new Random(System.currentTimeMillis());
var fuzzer = new Fuzzer();
- for (int i=0; i<1000000; i++)
- fuzzer.fuzzPeeps(i);
+ for (int i=0; i<100; i++)
+ fuzzer.fuzzPeeps(R.nextLong());
assertTrue(fuzzer.noExceptions());
}
+ @Ignore
@Test
- public void fuzzPeepsSmall() {
- Random R = new Random(System.currentTimeMillis());
+ public void fuzzPeepsLarge() {
var fuzzer = new Fuzzer();
- for (int i=0; i<100; i++)
- fuzzer.fuzzPeeps( R.nextLong());
+ for (int i=0; i<1000000; i++)
+ fuzzer.fuzzPeeps(i);
assertTrue(fuzzer.noExceptions());
}
@@ -40,4 +60,5 @@ public class FuzzerWrap {
for (int i=0; i<1000000; i++)
max_nid = fuzzer.fuzzPeepTiming(i, max_nid);
}
+
}