Base_quickcheck.ShrinkerShrinkers produce small values from large values. When a random test case fails, a shrinker finds the simplest version of the problem.
val atomic : _ tThis shrinker treats a type as atomic, never attempting to produce smaller values.
val string : Base.string tval int32 : Base.int32 tval int63 : Base.Int63.t tval int64 : Base.int64 tval nativeint : Base.nativeint tval float : Base.float tval sexp : Base.Sexp.t tval option : 'a t -> 'a Base.option tval either : 'a t -> 'b t -> ('a, 'b) Base.Either.t tval result : 'a t -> 'b t -> ('a, 'b) Base.Result.t tval map_t : 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.t tval set_t : 'elt t -> ('elt, 'cmp) Base.Set.t tval map_tree_using_comparator :
comparator:('key, 'cmp) Base.Comparator.t ->
'key t ->
'data t ->
('key, 'data, 'cmp) Base.Map.Using_comparator.Tree.t tval set_tree_using_comparator :
comparator:('elt, 'cmp) Base.Comparator.t ->
'elt t ->
('elt, 'cmp) Base.Set.Using_comparator.Tree.t tTies the recursive knot to shrink recursive types.
For example, here is an shrinker for binary trees:
let tree_shrinker leaf_shrinker =
fixed_point (fun self ->
either leaf_shrinker (both self self)
|> map
~f:(function
| First leaf -> `Leaf leaf
| Second (l, r) -> `Node (l, r))
~f_inverse:(function
| `Leaf leaf -> First leaf
| `Node (l, r) -> Second (l, r)))Most users will not need to call these.
val create : ('a -> 'a Base.Sequence.t) -> 'a tval shrink : 'a t -> 'a -> 'a Base.Sequence.t