jetCheck: also count CannotRestoreValue as attempts while shrinking

because some generators can be really long before they fail like this
This commit is contained in:
peter
2017-12-01 16:26:44 +01:00
parent c0a69a0b1c
commit 5b9114adb5
3 changed files with 7 additions and 7 deletions
@@ -89,8 +89,8 @@ class PropertyFailureImpl<T> implements PropertyFailure<T> {
try {
iteration.session.notifier.shrinkAttempt(PropertyFailureImpl.this, iteration);
T value = iteration.session.generator.getGeneratorFunction().apply(new ReplayDataStructure(node, iteration.sizeHint, customizer));
totalSteps++;
T value = iteration.session.generator.getGeneratorFunction().apply(new ReplayDataStructure(node, iteration.sizeHint, customizer));
CounterExampleImpl<T> example = CounterExampleImpl.checkProperty(iteration.session.property, value, customizer.writeChanges(node));
if (example != null) {
minimized = example;
+5 -5
View File
@@ -29,7 +29,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testListContainsDivisible() {
checkGeneratesExample(nonEmptyLists(integers()),
l -> l.stream().anyMatch(i -> i % 10 == 0),
3);
4);
}
public void testStringContains() {
@@ -108,7 +108,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
.shouldHold(s -> Character.isJavaIdentifierStart(s.charAt(0)) && s.chars().allMatch(Character::isJavaIdentifierPart));
checkGeneratesExample(asciiIdentifiers(),
s -> s.contains("_"),
8);
11);
}
public void testBoolean() {
@@ -121,7 +121,7 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testShrinkingNonEmptyList() {
List<Integer> list = checkGeneratesExample(nonEmptyLists(integers(0, 100)),
l -> l.contains(42),
11);
12);
assertEquals(1, list.size());
}
@@ -153,11 +153,11 @@ public class GeneratorTest extends PropertyCheckerTestCase {
public void testSameFrequency() {
checkFalsified(listsOf(frequency(1, constant(1), 1, constant(2))),
l -> !l.contains(1) || !l.contains(2),
2);
3);
checkFalsified(listsOf(frequency(1, constant(1), 1, constant(2)).with(1, constant(3))),
l -> !l.contains(1) || !l.contains(2) || !l.contains(3),
7);
8);
}
}
@@ -22,7 +22,7 @@ public class StatefulGeneratorTest extends PropertyCheckerTestCase {
});
List<InsertChar> minCmds = checkGeneratesExample(gen,
cmds -> InsertChar.performOperations(cmds).contains("ab"),
79);
89);
assertEquals(minCmds.toString(), 2, minCmds.size());
}