mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
jetCheck: refresh iteration seed on each attempt, otherwise recheck won't work
This commit is contained in:
@@ -10,5 +10,6 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.annotations.java5" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" scope="RUNTIME" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -23,23 +23,32 @@ class Iteration<T> {
|
||||
};
|
||||
|
||||
final CheckSession<T> session;
|
||||
final long iterationSeed;
|
||||
long iterationSeed;
|
||||
final int sizeHint;
|
||||
final int iterationNumber;
|
||||
private Random random;
|
||||
|
||||
Iteration(CheckSession<T> 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<T> findCounterExample(Random random) {
|
||||
private CounterExampleImpl<T> 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<T> {
|
||||
Iteration<T> performIteration() {
|
||||
session.notifier.iterationStarted(iterationNumber);
|
||||
|
||||
Random random = new Random(iterationSeed);
|
||||
CounterExampleImpl<T> example = findCounterExample(random);
|
||||
CounterExampleImpl<T> example = findCounterExample();
|
||||
if (example != null) {
|
||||
session.notifier.counterExampleFound(this);
|
||||
throw new PropertyFalsified(new PropertyFailureImpl<>(example, this));
|
||||
|
||||
@@ -205,7 +205,7 @@ class StructureNode extends StructureElement {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return children.hashCode();
|
||||
return children.hashCode() * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
|
||||
public void testSortedDoublesNonDescending() {
|
||||
PropertyFailure<List<Double>> failure = checkFalsified(listsOf(doubles()),
|
||||
l -> isSorted(l.stream().sorted().collect(Collectors.toList())),
|
||||
41);
|
||||
23);
|
||||
assertEquals(2, failure.getMinimalCounterexample().getExampleValue().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class PropertyCheckerTestCase extends TestCase {
|
||||
}
|
||||
|
||||
protected <T> PropertyFailure<T> checkFalsified(Generator<T> generator, Predicate<T> predicate, int minimizationSteps) {
|
||||
PropertyFalsified e = checkFails(forAllStable(generator), predicate);
|
||||
PropertyFalsified e = checkFails(forAllStable(generator).withIterationCount(1000), predicate);
|
||||
//noinspection unchecked
|
||||
PropertyFailure<T> failure = (PropertyFailure<T>)e.getFailure();
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
|
||||
});
|
||||
List<InsertChar> 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" +
|
||||
|
||||
Reference in New Issue
Block a user