QCheck.Shrink
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.t
Given a counter-example, return an iterator on smaller versions of the counter-example.
val nil : 'a t
No shrink
val unit : unit t
val char : char t
Shrinks towards 'a'
.
val char_numeral : char t
Shrinks towards '0'
.
val char_printable : char t
Shrinks towards 'a'
like !char
. The output is also a printable character.
val int : int t
val int32 : int32 t
val int64 : int64 t
filter f shrink
shrinks values the same as shrink
, but only keep smaller values that satisfy f
. This way it's easy to preserve invariants that are enforced by generators, when shrinking values
val int_aggressive : int t
Shrink integers by trying all smaller integers (can take a lot of time!)
val list_spine : 'a list t
Try to shrink lists by removing one or more elements.
pair a b
uses a
to shrink the first element of tuples, then tries to shrink the second element using b
. 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.
tup2 a b
uses a
to shrink the first element of tuples, then tries to shrink the second element using b
. 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.
Similar to tup2
val tup7 :
'a t ->
'b t ->
'c t ->
'd t ->
'e t ->
'f t ->
'g t ->
('a * 'b * 'c * 'd * 'e * 'f * 'g) t
Similar to tup2