|
1 | 1 | package fj.test; |
2 | 2 |
|
| 3 | +import fj.Equal; |
3 | 4 | import fj.F; |
| 5 | +import fj.F1Functions; |
4 | 6 | import fj.F2; |
5 | 7 | import fj.F3; |
6 | 8 | import fj.F4; |
|
11 | 13 | import fj.Function; |
12 | 14 | import fj.Bottom; |
13 | 15 |
|
| 16 | +import static fj.Equal.longEqual; |
14 | 17 | import static fj.Function.compose; |
15 | 18 | import static fj.P.p; |
16 | 19 |
|
|
37 | 40 | import fj.data.List; |
38 | 41 | import fj.data.Set; |
39 | 42 | import fj.data.TreeMap; |
| 43 | +import fj.function.Booleans; |
40 | 44 | import fj.function.Effect1; |
| 45 | +import fj.function.Longs; |
41 | 46 |
|
42 | 47 | import static fj.data.Stream.range; |
| 48 | +import static fj.function.Booleans.not; |
43 | 49 | import static fj.test.Gen.choose; |
44 | 50 | import static fj.test.Gen.elements; |
45 | 51 | import static fj.test.Gen.fail; |
@@ -469,6 +475,12 @@ public Gen<Short> f(final Integer i) { |
469 | 475 | } |
470 | 476 | }); |
471 | 477 |
|
| 478 | + /** |
| 479 | + * An arbitrary implementation for naturals. |
| 480 | + */ |
| 481 | + public static final Gen<Natural> arbNatural = arbLong.filter(not(longEqual.eq(Long.MIN_VALUE))) |
| 482 | + .map(Longs.abs).map(Natural::natural).map(o -> o.some()); |
| 483 | + |
472 | 484 | /** |
473 | 485 | * An arbitrary implementation for character values. |
474 | 486 | */ |
@@ -760,7 +772,7 @@ public static <A> Gen<ArrayList<A>> arbArrayList(final Gen<A> aa) { |
760 | 772 | /** |
761 | 773 | * Returns an arbitrary implementation for a Java enumeration. |
762 | 774 | * |
763 | | - * @param clazz The type of enum to return an arbtrary of. |
| 775 | + * @param clazz The type of enum to return an arbitrary of. |
764 | 776 | * @return An arbitrary for instances of the supplied enum type. |
765 | 777 | */ |
766 | 778 | public static <A extends Enum<A>> Gen<A> arbEnumValue(final Class<A> clazz) { |
@@ -1337,4 +1349,5 @@ public static <A, B, C, D, E> Gen<P5<A, B, C, D, E>> arbP5(final Gen<A> aa, fina |
1337 | 1349 | return aa.bind(ab, ac, ad, ae, af, ag, ah, |
1338 | 1350 | a -> b -> c -> d -> e -> f -> g -> h -> p(a, b, c, d, e, f, g, h)); |
1339 | 1351 | } |
| 1352 | + |
1340 | 1353 | } |
0 commit comments