Skip to content

Commit 34534a8

Browse files
authored
Merge pull request #278 from bakeemawaytoys/Natural_Gen_Shrink
Switched the the Gen and Shrink implementations for Natural to use Bi…
2 parents 9e70768 + 56508b6 commit 34534a8

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

quickcheck/src/main/java/fj/test/Arbitrary.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,6 @@ public Gen<Short> f(final Integer i) {
475475
}
476476
});
477477

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-
484478
/**
485479
* An arbitrary implementation for character values.
486480
*/
@@ -1179,6 +1173,11 @@ public static <A> Gen<SynchronousQueue<A>> arbSynchronousQueue(final Gen<A> aa)
11791173

11801174
// END java.math
11811175

1176+
/**
1177+
* An arbitrary implementation for naturals.
1178+
*/
1179+
public static final Gen<Natural> arbNatural = arbBigInteger.map(BigInteger::abs).map(Natural::natural).map(o -> o.some());
1180+
11821181
/**
11831182
* An arbitrary implementation for locales.
11841183
*/

quickcheck/src/main/java/fj/test/Shrink.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ public static <A> Shrink<A> empty() {
184184
*/
185185
public static final Shrink<Double> shrinkDouble = shrinkLong.map(Long_Double, Double_Long);
186186

187-
/**
188-
* A shrink strategy for naturals.
189-
*/
190-
public static final Shrink<Natural> shrinkNatural = shrinkLong.map(l -> Natural.natural(l).orSome(Natural.ZERO), Natural::longValue);
191187

192188
/**
193189
* Returns a shrink strategy for optional values. A 'no value' is already fully
@@ -701,6 +697,12 @@ public static <A> Shrink<SynchronousQueue<A>> shrinkSynchronousQueue(final Shrin
701697

702698
// END java.math
703699

700+
/**
701+
* A shrink strategy for naturals.
702+
*/
703+
public static final Shrink<Natural> shrinkNatural = shrinkBigInteger.map(l -> Natural.natural(l).orSome(Natural.ZERO), Natural::bigIntegerValue);
704+
705+
704706
/**
705707
* Returns a shrinking strategy for product-1 values.
706708
*

0 commit comments

Comments
 (0)