package bam
Library
Module
Module type
Parameter
Class
Class type
This module contains the various strinking strategies which can be used with the generators below.
type 'a t =
| Default : 'a t
(*Default strategy for all the generators defined in this module. Refer to the documentation of each generator to know what the default strategy is.
*)| Manual : ('a -> 'a Stdlib.Seq.t) -> 'a t
(*Instead of relying on a built-in strategy, anyone can define its own shrinking strategy. To do so, given a value, the user must provide a sequence of "smaller" values.
*)| Pair_left : ('a * 'b) t
(*Shrinking strategy for pairs where the first component is shrunk first.
*)| Pair_right : ('a * 'b) t
(*Shrinking strategy for pairs where the second component is shrunk first.
*)| Pair_compare : (('a * 'b) -> ('a * 'b) -> Stdlib.Int.t) -> ('a * 'b) t
(*Shrinking strategy for pairs where the function comparison is given to know which pair to handle first. For example
*)Pair_compare (fun _ _ -> -1)
is equivalent toPair_left
.Pair_compare (fun left right -> compare (fst left + snd left) (fst right + snd right))
handles pair of integers by minimizing first the sum of their component.| Char : Stdlib.Char.t -> Stdlib.Char.t t
(*Shrinking strategy for chars. The shrinker will try to reduce samples to the char given.
*)| Bool : Stdlib.Bool.t -> Stdlib.Bool.t t
(*Shrinking strategy for bool. The shrinker will try to reduce samples to the bool given.
*)| Float : Stdlib.Float.t -> Stdlib.Float.t t
(*Shrinking strategy for float. The shrinker will try to reduce samples to the float given.
The strategy split the initial float into a pair of a fractional and integral part. Then the strategy behaves as
Pair_left
where the first component is the integral part and the second component is the fractional part. The shrinking behavior for the integral part behaves as theInt n
strategy wheren
is the integral part of the float given. The shrinking behavior for the fractional part tries to minimize the number of decimals.This strategy is syntactic sugar for
*)Float_precision
withexhaustive_search_digits=0
andprecision_digits=15
.| Float_precision : {
} -> Stdlib.Float.t t
(*This shrinking strategy allows to enumerate the float numbers that can be represented with
*)exhaustive_search_digits
digits. Whileprecision_digits
allows the search up toprecision_digits
digits with respect to the original counter-example.arget
is the same asFloat
.| Int : Stdlib.Int.t -> Stdlib.Int.t t
(*Shrinking strategy for int. The shrinker will try to reduce samples to the int given. The strategy follows a binary search starting with the initial sample to the integer provided by the strategy.
*)| Int32 : Stdlib.Int32.t -> Stdlib.Int32.t t
| Int64 : Stdlib.Int64.t -> Stdlib.Int64.t t
| Skip : {
} -> 'a Stdlib.List.t t
(*Shrinking strategy for lists. The shrinker will try to reduce first on the size on the list and then shrink the elements of the lists. This strategy will try to shrink to a smaller list by skipping some elements.
Assuming the initial sample is
a;b;c;d
, it can first shrink towards a list of size2
such asa;c
orb;d
, while the prefix strategy can always shrink to a prefix. Hence for a list of size2
it must bea;b
(and then the shrinking will shrink ona
andb
individually).With
*)`Auto
, the tool tries to infer a good value so that the shrinking strategy remains short. With`Int n
, the user provides the number of elements that can be skipped. This can be quite time consuming since such a strategy is at least exponential with respect to the initial size of the list.| Prefix : 'a Stdlib.List.t t
(*Shrinking strategy for lists. The shrinker will try to reduce first on the size on the list and then shrink the elements of the lists. The strategy will shrink towards a prefix of the list.
*)| Suffix : 'a Stdlib.List.t t
(*Shrinking strategy for lists. The shrinker will try to reduce first on the size on the list and then shrink the elements of the lists. The strategy will shrink towards a suffix of the list.
*)