0
|
1 package fj.data.test;
|
|
2
|
|
3 import fj.F2;
|
|
4 import fj.F3;
|
|
5 import fj.data.List;
|
|
6 import fj.test.Arbitrary;
|
|
7 import fj.test.CheckResult;
|
|
8 import fj.test.Gen;
|
|
9 import fj.test.Property;
|
|
10 import org.junit.*;
|
|
11
|
|
12 import static fj.Function.compose;
|
|
13 import static fj.test.Arbitrary.*;
|
|
14 import static fj.test.Arbitrary.arbLong;
|
|
15 import static fj.test.Coarbitrary.coarbInteger;
|
|
16 import static fj.test.Coarbitrary.coarbLong;
|
|
17 import static fj.test.Property.prop;
|
|
18 import static fj.test.Property.property;
|
|
19 import static org.junit.Assert.*;
|
|
20
|
|
21 public class TestCheck {
|
|
22
|
|
23 @Test(timeout=1000 /*ms*/)
|
|
24 public void testExceptionsThrownFromGeneratorsArePropagated() {
|
|
25 Gen<Integer> failingGen = Gen.<Integer>value(0).map((i) -> {
|
|
26 throw new RuntimeException("test failure");
|
|
27 });
|
|
28
|
|
29 Property p = property(arbitrary(failingGen), (Integer i) -> {
|
|
30 return prop(i == 0);
|
|
31 });
|
|
32
|
|
33 CheckResult res = p.check(
|
|
34 1, /*minSuccessful*/
|
|
35 0, /*maxDiscarded*/
|
|
36 0, /*minSize*/
|
|
37 1 /*maxSize*/
|
|
38 );
|
|
39 assertTrue("Exception not propagated!", res.isGenException());
|
|
40 }
|
|
41 }
|