Skip to content

Commit 221c0d6

Browse files
committed
Added quickcheck test for stream properties that matches unstable scalacheck test. Increased timeout for TestCheck
1 parent e15ea09 commit 221c0d6

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fj.data;
2+
3+
import fj.Equal;
4+
import fj.test.Gen;
5+
import fj.test.Property;
6+
import fj.test.reflect.CheckParams;
7+
import fj.test.runner.PropertyTestRunner;
8+
import org.junit.runner.RunWith;
9+
10+
import static fj.test.Arbitrary.*;
11+
import static fj.test.Property.prop;
12+
import static fj.test.Property.property;
13+
14+
/**
15+
* Created by MarkPerry on 18/06/2015.
16+
*/
17+
@RunWith(PropertyTestRunner.class)
18+
@CheckParams(maxSize = 10000)
19+
public class StreamProperties {
20+
21+
public Property bindStackOverflow() {
22+
int max = 5000;
23+
return property(arbitrary(Gen.choose(1, max)), (n) -> {
24+
Stream<Integer> s1 = Stream.range(1, n);
25+
Stream<Integer> s2 = s1.bind(j -> Stream.single(j));
26+
return prop(s1.zip(s2).forall(p2 -> Equal.intEqual.eq(p2._1(), p2._2())));
27+
});
28+
}
29+
30+
}

quickcheck/src/test/java/fj/data/test/TestCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class TestCheck {
2222

23-
@Test(timeout=1000 /*ms*/)
23+
@Test(timeout=5000 /*ms*/)
2424
public void testExceptionsThrownFromGeneratorsArePropagated() {
2525
Gen<Integer> failingGen = Gen.<Integer>value(0).map((i) -> {
2626
throw new RuntimeException("test failure");

0 commit comments

Comments
 (0)