@API(status=STABLE, since="1.0") public interface Shrinkable<T> extends java.lang.Comparable<Shrinkable<T>>
Modifier and Type | Interface and Description |
---|---|
static class |
Shrinkable.ShrinkableFacade |
Modifier and Type | Method and Description |
---|---|
default Shrinkable<java.lang.Object> |
asGeneric()
Sometimes simplifies test writing
|
default int |
compareTo(Shrinkable<T> other) |
ShrinkingDistance |
distance() |
default Shrinkable<T> |
filter(java.util.function.Predicate<T> filter) |
default <U> Shrinkable<U> |
flatMap(java.util.function.Function<T,Arbitrary<U>> flatMapper,
int tries,
long randomSeed) |
default java.util.stream.Stream<Shrinkable<T>> |
grow()
Grow a shrinkable to allow broader searching in flat mapped shrinkables
|
default java.util.Optional<Shrinkable<T>> |
grow(Shrinkable<?> before,
Shrinkable<?> after)
To be able to "move" values towards the end of collections while keeping some constraint constant
it's necessary to grow a shrinkable by what another has been shrunk.
|
default Shrinkable<T> |
makeUnshrinkable() |
default <U> Shrinkable<U> |
map(java.util.function.Function<T,U> mapper) |
java.util.stream.Stream<Shrinkable<T>> |
shrink()
Create a new and finite stream of smaller or same size shrinkables; size is measured by distance().
|
default ShrinkingSequence<T> |
shrink(Falsifier<T> falsifier)
Deprecated.
Will be removed in version 1.4
|
static <T> Shrinkable<T> |
supplyUnshrinkable(java.util.function.Supplier<T> supplier) |
static <T> Shrinkable<T> |
unshrinkable(T value) |
static <T> Shrinkable<T> |
unshrinkable(T value,
ShrinkingDistance distance) |
T |
value()
Create value freshly, so that in case of mutable objects shrinking (and reporting)
can rely on untouched values.
|
static <T> Shrinkable<T> unshrinkable(T value)
static <T> Shrinkable<T> unshrinkable(T value, ShrinkingDistance distance)
@API(status=INTERNAL) static <T> Shrinkable<T> supplyUnshrinkable(java.util.function.Supplier<T> supplier)
T value()
@API(status=INTERNAL, since="1.3.3") java.util.stream.Stream<Shrinkable<T>> shrink()
Same size shrinkables are allowed but they have to iterate towards a single value to prevent endless shrinking. This also means that a shrinkable must never be in its own shrink stream!
@API(status=INTERNAL, since="1.3.3") default java.util.Optional<Shrinkable<T>> grow(Shrinkable<?> before, Shrinkable<?> after)
before
- The other shrinkable before shrinkingafter
- The other shrinkable after shrinking@API(status=INTERNAL, since="1.3.3") default java.util.stream.Stream<Shrinkable<T>> grow()
@Deprecated @API(status=DEPRECATED, since="1.3.3") default ShrinkingSequence<T> shrink(Falsifier<T> falsifier)
ShrinkingDistance distance()
@API(status=INTERNAL, since="1.2.4") default Shrinkable<java.lang.Object> asGeneric()
default <U> Shrinkable<U> map(java.util.function.Function<T,U> mapper)
default Shrinkable<T> filter(java.util.function.Predicate<T> filter)
default <U> Shrinkable<U> flatMap(java.util.function.Function<T,Arbitrary<U>> flatMapper, int tries, long randomSeed)
@API(status=INTERNAL) default int compareTo(Shrinkable<T> other)
compareTo
in interface java.lang.Comparable<Shrinkable<T>>
@API(status=INTERNAL) default Shrinkable<T> makeUnshrinkable()