Up

Module type Quickcheck

Signature

type 'a gen
type 'a obs
type 'a shr
module Generator : Generator with type 'a t = 'a gen with type 'a obs := 'a obs
module Observer : Observer with type 'a t = 'a obs with type 'a gen := 'a gen
module Shrinker : Shrinker with type 'a t = 'a shr
module Make_int (M : Pre_int) : S_bounded with type t := M.t with type 'a gen := 'a gen with type 'a obs := 'a obs with type 'a shr := 'a shr
module For_int : S_bounded with type t := int with type 'a gen := 'a gen with type 'a obs := 'a obs with type 'a shr := 'a shr
include Quickcheck_configured with type 'a gen := 'a gen with type 'a shr := 'a shr
include Quickcheck_config
val default_seed : seed

default_seed is used initialize the pseudo-random generator that chooses random values from generators, in each test that is not provided its own seed.

val default_trial_count : int

default_trial_count determines the number of trials per test, except in tests that explicitly override it.

val default_trial_count_for_test_no_duplicates : [
| `Constant of int
| `Scale_of_default_trial_count of float
]

default_trial_count_for_test_no_duplicates determines the number of trials when running test_no_duplicates without ~trials, either as a constant or as a factor of default_trial_count.

val default_attempts_per_trial : float

default_attempts_per_trial determines the maximum number of attempts to generate inputs for trials, as a multiplier for the number of trials, except in tests that explicitly override it.

val default_probability_threshold_to_remember_choice : float

default_probability_threshold_to_remember_choice determines the minimum probability, out of 1.0, at which Quickcheck.iter and derived functions will remember previous choices and avoid repeating them. Below this threshold, it is assumed that the space needed to record the choice outweighs the negligible chance of repeating it.

val default_shrink_attempts : shrink_attempts

default_shrink_attempts determines the number of attempts at shrinking when running test or iter with ~shrinker and without ~shrink_attempts

type 'a gen
type 'a shr
val random_value : ?seed:seed -> 'a gen -> 'a

random_value ~seed gen produces a single value chosen from gen using seed.

val iter : ?seed:seed -> ?trials:int -> ?attempts:int -> ?probability_threshold_to_remember_choice:float -> 'a gen -> f:('a -> unit) -> unit

iter ~seed ~trials ~attempts gen ~f runs f on up to trials different values generated by gen. It stops successfully after trials successful trials or if gen runs out of values. It raises an exception if f raises an exception or if it fails to produce trials inputs from gen after attempts attempts.

val test : ?seed:seed -> ?trials:int -> ?attempts:int -> ?shrinker:'a shr -> ?shrink_attempts:shrink_attempts -> ?probability_threshold_to_remember_choice:float -> ?sexp_of:('a -> Sexp.t) -> ?examples:'a list -> 'a gen -> f:('a -> unit) -> unit

test ~seed ~trials ~attempts ~sexp_of ~examples gen ~f is like iter, with optional concrete examples that are tested before values from gen, and additional information provided on failure. If f raises an exception and sexp_of is provided, the exception is re-raised with a description of the random input that triggered the failure. If f raises an exception and shrinker is provided, it will be used to attempt to shrink the value that caused the exception with re-raising behaving the same as for unshrunk inputs.

val test_can_generate : ?seed:seed -> ?trials:int -> ?attempts:int -> ?probability_threshold_to_remember_choice:float -> ?sexp_of:('a -> Sexp.t) -> 'a gen -> f:('a -> bool) -> unit

test_can_generate ~seed ~trials ~attempts ~sexp_of gen ~f is useful for testing gen values, to make sure they can generate useful examples. It tests gen by generating up to trials values and passing them to f. Once a value satisfies f, the iteration stops. If no values satisfy f, test_can_generate raises an exception. If sexp_of is provided, the exception includes all of the generated values.

val test_no_duplicates : ?seed:seed -> ?trials:int -> ?attempts:int -> ?probability_threshold_to_remember_choice:float -> ?sexp_of:('a -> Sexp.t) -> 'a gen -> by:[
| `Equal of 'a -> 'a -> bool
| `Compare of 'a -> 'a -> int
] -> unit

test_no_duplicates ~seed ~trials ~attempts ~sexp_of gen ~by is useful for testing gen values, to make sure they do not create duplicate values. It tests gen by generating up to trials values and comparing each pair of the generated values using by. If any of the pairs are identical, test_no_duplicates raises an exception. If sexp_of is provided, the exception includes the identical values.

val random_sequence : ?seed:seed -> ?probability_threshold_to_remember_choice:float -> 'a gen -> 'a Core_kernel.Sequence.t

random_sequence ~seed gen produces a sequence of values chosen from gen.

val random_state_of_seed : seed -> Core_kernel.Core_random.State.t

random_state_of_seed constructs initial random states for a given seed. This is intended for building extensions to this interface, rather than for use in individual tests.