Add test to demonstrate shrinking in presence of When(satisfies)
@@ -230,10 +230,34 @@ public class ShrinkingTest {
@RunWith(JUnitQuickcheck.class)
public static class ShrinkingTimeout {
- @Property(maxShrinks = Integer.MAX_VALUE, maxShrinkDepth = Integer.MAX_VALUE, maxShrinkTime = 200)
+ @Property(
+ maxShrinks = Integer.MAX_VALUE,
+ maxShrinkDepth = Integer.MAX_VALUE,
+ maxShrinkTime = 200)
public void shouldHold(Foo f) throws InterruptedException {
assumeThat(f.slow(), greaterThan(Integer.MAX_VALUE / 2));
assertThat(f.slow(), lessThan(Integer.MAX_VALUE / 2));
}
}
+
+ @Test public void shrinkingInPresenceOfConstraintExpression() {
+ assertThat(
+ testResult(ShrinkingInPresenceOfConstraintExpression.class),
+ failureCountIs(1));
+ assertTrue(
+ ShrinkingInPresenceOfConstraintExpression.values
+ .stream()
+ .allMatch(f -> f.i() >= 0));
+ }
+
+ @RunWith(JUnitQuickcheck.class)
+ public static class ShrinkingInPresenceOfConstraintExpression {
+ private static List<Foo> values = new ArrayList<>();
+
+ @Property public void shouldHold(@When(satisfies = "#_.i >= 0") Foo f) {
+ values.add(f);
+
+ fail();
+ }
+ }
}
