Module Base_quickcheck.Shrinker
Shrinkers produce small values from large values. When a random test case fails, a shrinker finds the simplest version of the problem.
Basic Shrinkers
- val atomic : _ t
- This shrinker treats a type as atomic, never attempting to produce smaller values. 
- val unit : Base.unit t
- val bool : Base.bool t
- val char : Base.char t
- val string : Base.string t
- val int : Base.int t
- val int32 : Base.int32 t
- val int63 : Base.Int63.t t
- val int64 : Base.int64 t
- val nativeint : Base.nativeint t
- val float : Base.float t
- val sexp : Base.Sexp.t t
- val option : 'a t -> 'a Base.option t
- val list : 'a t -> 'a Base.list t
- val both : 'a t -> 'b t -> ('a * 'b) t
- val either : 'a t -> 'b t -> ('a, 'b) Base.Either.t t
- val result : 'a t -> 'b t -> ('a, 'b) Base.Result.t t
- val map_t : 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.t t
- val set_t : 'elt t -> ('elt, 'cmp) Base.Set.t t
- val map_tree_using_comparator : comparator:('key, 'cmp) Base.Comparator.t -> 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.Using_comparator.Tree.t t
- val set_tree_using_comparator : comparator:('elt, 'cmp) Base.Comparator.t -> 'elt t -> ('elt, 'cmp) Base.Set.Using_comparator.Tree.t t
Modifying Shrinkers
Shrinkers for Recursive Types
- val fixed_point : ('a t -> 'a t) -> 'a t
- Ties 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)))
Low-level functions
Most users will not need to call these.
- val create : ('a -> 'a Base.Sequence.t) -> 'a t
- val shrink : 'a t -> 'a -> 'a Base.Sequence.t