diff src/test/java/fj/data/test/TestCheck.java @ 0:fe80c1edf1be

add getLoop
author tatsuki
date Fri, 20 Mar 2015 21:04:03 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/fj/data/test/TestCheck.java	Fri Mar 20 21:04:03 2015 +0900
@@ -0,0 +1,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());
+	}
+}