Module QCheck.Shrink
Shrink Values
Shrinking is used to reduce the size of a counter-example. It tries to make the counter-example smaller by decreasing it, or removing elements, until the property to test holds again; then it returns the smallest value that still made the test fail.
type 'a t= 'a -> 'a Iter.tGiven a counter-example, return an iterator on smaller versions of the counter-example.
val nil : 'a tNo shrink
val unit : unit t- since
- 0.6
val char : char t- since
- 0.6
val int64 : int64 t- since
- 0.14
val option : 'a t -> 'a option tval string : string tval filter : ('a -> bool) -> 'a t -> 'a tfilter f shrinkshrinks values the same asshrink, but only keep smaller values that satisfyf. This way it's easy to preserve invariants that are enforced by generators, when shrinking values- since
- 0.8
val int_aggressive : int tShrink integers by trying all smaller integers (can take a lot of time!)
- since
- 0.7
val list : ?shrink:'a t -> 'a list tTry to shrink lists by removing one or more elements.
- parameter shrink
if provided, will be used to also try to reduce the elements of the list themselves (e.g. in an
int listone can try to decrease the integers).
val list_spine : 'a list tTry to shrink lists by removing one or more elements.
- since
- 0.10
val list_elems : 'a t -> 'a list tShrinks the elements of a list, without changing the list size.
- since
- 0.10
val pair : 'a t -> 'b t -> ('a * 'b) tpair a busesato shrink the first element of tuples, then tries to shrink the second element usingb. It is often better, when generating tuples, to put the "simplest" element first (atomic type rather than list, etc.) because it will be shrunk earlier. In particular, putting functions last might help.