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 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) -> 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 : Char.t -> Char.t t
(*Shrinking strategy for chars. The shrinker will try to reduce samples to the char given.
*)| Bool : Bool.t -> Bool.t t
(*Shrinking strategy for bool. The shrinker will try to reduce samples to the bool given.
*)| Float : Float.t -> 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 : {
exhaustive_search_digits : int;
precision_digits : int;
target : Float.t;
} -> 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 : Int.t -> 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 : Int32.t -> Int32.t t
| Int64 : Int64.t -> Int64.t t
| Skip : {
eq : 'a -> 'a -> bool;
skip : [ `Auto | `Int of Int.t ];
} -> 'a 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 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 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.
*)
val skip_auto : 'a list t
skip_auto
is an alias for Skip {eq=(=); skip=`Auto}