package bam

  1. Overview
  2. Docs

This module contains the various strinking strategies which can be used with the generators below.

type 'a t =
  1. | 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.

    *)
  2. | 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.

    *)
  3. | Pair_left : ('a * 'b) t
    (*

    Shrinking strategy for pairs where the first component is shrunk first.

    *)
  4. | Pair_right : ('a * 'b) t
    (*

    Shrinking strategy for pairs where the second component is shrunk first.

    *)
  5. | 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 to Pair_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.

    *)
  6. | Char : Stdlib.Char.t -> Stdlib.Char.t t
    (*

    Shrinking strategy for chars. The shrinker will try to reduce samples to the char given.

    *)
  7. | Bool : Stdlib.Bool.t -> Stdlib.Bool.t t
    (*

    Shrinking strategy for bool. The shrinker will try to reduce samples to the bool given.

    *)
  8. | 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 the Int n strategy where n 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 with exhaustive_search_digits=0 and precision_digits=15.

    *)
  9. | Float_precision : {
    1. exhaustive_search_digits : int;
    2. precision_digits : int;
    3. target : Stdlib.Float.t;
    } -> Stdlib.Float.t t
    (*

    This shrinking strategy allows to enumerate the float numbers that can be represented with exhaustive_search_digits digits. While precision_digits allows the search up to precision_digits digits with respect to the original counter-example. arget is the same as Float.

    *)
  10. | 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.

    *)
  11. | Int32 : Stdlib.Int32.t -> Stdlib.Int32.t t
    (*

    See Int

    *)
  12. | Int64 : Stdlib.Int64.t -> Stdlib.Int64.t t
    (*

    See Int

    *)
  13. | Skip : {
    1. eq : 'a -> 'a -> bool;
    2. skip : [ `Auto | `Int of Stdlib.Int.t ];
    } -> '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 size 2 such as a;c or b;d, while the prefix strategy can always shrink to a prefix. Hence for a list of size 2 it must be a;b (and then the shrinking will shrink on a and b 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.

    *)
  14. | 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.

    *)
  15. | 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.

    *)
OCaml

Innovation. Community. Security.