forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCheck.java
More file actions
41 lines (35 loc) · 1 KB
/
Copy pathTestCheck.java
File metadata and controls
41 lines (35 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package fj.data.test;
import fj.F2;
import fj.F3;
import fj.data.List;
import fj.test.Arbitrary;
import fj.test.CheckResult;
import fj.test.Gen;
import fj.test.Property;
import org.junit.*;
import static fj.Function.compose;
import static fj.test.Arbitrary.*;
import static fj.test.Arbitrary.arbLong;
import static fj.test.Coarbitrary.coarbInteger;
import static fj.test.Coarbitrary.coarbLong;
import static fj.test.Property.prop;
import static fj.test.Property.property;
import static org.junit.Assert.*;
public class TestCheck {
@Test(timeout=1000 /*ms*/)
public void testExceptionsThrownFromGeneratorsArePropagated() {
Gen<Integer> failingGen = Gen.<Integer>value(0).map((i) -> {
throw new RuntimeException("test failure");
});
Property p = property(arbitrary(failingGen), (Integer i) -> {
return prop(i == 0);
});
CheckResult res = p.check(
1, /*minSuccessful*/
0, /*maxDiscarded*/
0, /*minSize*/
1 /*maxSize*/
);
assertTrue("Exception not propagated!", res.isGenException());
}
}