diff --git a/jetCheck/intellij.tools.jetCheck.iml b/jetCheck/intellij.tools.jetCheck.iml
index e91aa41a19e2..a0324d9fa107 100644
--- a/jetCheck/intellij.tools.jetCheck.iml
+++ b/jetCheck/intellij.tools.jetCheck.iml
@@ -10,5 +10,6 @@
+
\ No newline at end of file
diff --git a/jetCheck/src/org/jetbrains/jetCheck/Iteration.java b/jetCheck/src/org/jetbrains/jetCheck/Iteration.java
index 5a822aa05bea..5f025524abfe 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/Iteration.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/Iteration.java
@@ -23,23 +23,32 @@ class Iteration {
};
final CheckSession session;
- final long iterationSeed;
+ long iterationSeed;
final int sizeHint;
final int iterationNumber;
+ private Random random;
Iteration(CheckSession session, long iterationSeed, int iterationNumber) {
this.session = session;
- this.iterationSeed = iterationSeed;
this.sizeHint = session.sizeHintFun.applyAsInt(iterationNumber);
this.iterationNumber = iterationNumber;
if (sizeHint < 0) {
throw new IllegalArgumentException("Size hint should be non-negative, found " + sizeHint);
}
+ initSeed(iterationSeed);
+ }
+
+ private void initSeed(long seed) {
+ iterationSeed = seed;
+ random = new Random(seed);
}
@Nullable
- private CounterExampleImpl findCounterExample(Random random) {
+ private CounterExampleImpl findCounterExample() {
for (int i = 0; i < 100; i++) {
+ if (i > 0) {
+ initSeed(random.nextLong());
+ }
StructureNode node = new StructureNode(new NodeId(session.generator));
T value;
try {
@@ -75,8 +84,7 @@ class Iteration {
Iteration performIteration() {
session.notifier.iterationStarted(iterationNumber);
- Random random = new Random(iterationSeed);
- CounterExampleImpl example = findCounterExample(random);
+ CounterExampleImpl example = findCounterExample();
if (example != null) {
session.notifier.counterExampleFound(this);
throw new PropertyFalsified(new PropertyFailureImpl<>(example, this));
diff --git a/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java b/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java
index a2afed65a0aa..0bac624a566a 100644
--- a/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java
+++ b/jetCheck/src/org/jetbrains/jetCheck/StructureNode.java
@@ -205,7 +205,7 @@ class StructureNode extends StructureElement {
@Override
public int hashCode() {
- return children.hashCode();
+ return children.hashCode() * 3;
}
@Override
diff --git a/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java b/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java
index d933b38a6992..4ee859583a8f 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/GeneratorTest.java
@@ -60,7 +60,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testSortedDoublesNonDescending() {
PropertyFailure> failure = checkFalsified(listsOf(doubles()),
l -> isSorted(l.stream().sorted().collect(Collectors.toList())),
- 41);
+ 23);
assertEquals(2, failure.getMinimalCounterexample().getExampleValue().size());
}
diff --git a/jetCheck/test/org/jetbrains/jetCheck/PropertyCheckerTestCase.java b/jetCheck/test/org/jetbrains/jetCheck/PropertyCheckerTestCase.java
index e49633d79e74..9a0e3a205e9e 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/PropertyCheckerTestCase.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/PropertyCheckerTestCase.java
@@ -27,7 +27,7 @@ abstract class PropertyCheckerTestCase extends TestCase {
}
protected PropertyFailure checkFalsified(Generator generator, Predicate predicate, int minimizationSteps) {
- PropertyFalsified e = checkFails(forAllStable(generator), predicate);
+ PropertyFalsified e = checkFails(forAllStable(generator).withIterationCount(1000), predicate);
//noinspection unchecked
PropertyFailure failure = (PropertyFailure)e.getFailure();
diff --git a/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java b/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java
index fb7f9e2440ae..7153086b1d84 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/ShrinkTest.java
@@ -21,7 +21,7 @@ public class ShrinkTest extends PropertyCheckerTestCase {
String s = l.toString();
return !"abcdefghijklmnopqrstuvwxyz()[]#!".chars().allMatch(c -> s.indexOf((char)c) >= 0);
},
- 258);
+ 254);
}
public void testShrinkingNonEmptyList() {
diff --git a/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java b/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java
index d43d45c9935e..c43dbfcf0f83 100644
--- a/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java
+++ b/jetCheck/test/org/jetbrains/jetCheck/StatefulGeneratorTest.java
@@ -29,7 +29,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
});
List minCmds = checkGeneratesExample(gen,
cmds -> InsertChar.performOperations(cmds).contains("ab"),
- 64);
+ 36);
assertEquals(minCmds.toString(), 2, minCmds.size());
}
@@ -37,7 +37,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
Scenario minHistory = checkFalsified(ImperativeCommand.scenarios(() -> env -> {
StringBuilder sb = new StringBuilder();
env.executeCommands(withRecursion(insertStringCmd(sb), deleteStringCmd(sb), checkDoesNotContain(sb, "A")));
- }), Scenario::ensureSuccessful, 42).getMinimalCounterexample().getExampleValue();
+ }), Scenario::ensureSuccessful, 33).getMinimalCounterexample().getExampleValue();
assertEquals("commands:\n" +
" insert A at 0\n" +
@@ -56,7 +56,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
};
env.executeCommands(withRecursion(insertStringCmd(sb), replace, deleteStringCmd(sb), checkDoesNotContain(sb, "A")));
- }), Scenario::ensureSuccessful, 76).getMinimalCounterexample().getExampleValue();
+ }), Scenario::ensureSuccessful, 56).getMinimalCounterexample().getExampleValue();
assertEquals("commands:\n" +
" insert A at 0\n" +