Filters the values produced by this generator, discarding any values that do not meet the specified predicate.
Filters the values produced by this generator, discarding any values that
do not meet the specified predicate. Using filter
can reduce test
performance, especially if many values must be discarded. It is
recommended to use combinators such as map
and flatMap
to create
generators of the desired values instead.
val evens: Gen[Random, Int] = Gen.anyInt.map(_ * 2)
Maps an effectual function over a generator.
Discards the shrinker for this generator and applies a new shrinker by mapping each value to a sample using the specified function.
Discards the shrinker for this generator and applies a new shrinker by mapping each value to a sample using the specified function. This is useful when the process to shrink a value is simpler than the process used to generate it.
A
Gen[R, A]
represents a generator of values of typeA
, which requires an environmentR
. Generators may be random or deterministic.