Up

Module Quickcheck = Core_kernel.Quickcheck

Signature

include Core_kernel.Quickcheck_intf.Quickcheck
type 'a gen
type 'a obs
type 'a shr
module Generator : Quickcheck_intf.Generator with type 'a t = 'a gen with type 'a obs := 'a obs
module Observer : Quickcheck_intf.Observer with type 'a t = 'a obs with type 'a gen := 'a gen
module Shrinker : Quickcheck_intf.Shrinker with type 'a t = 'a shr
module Make_int (M : Quickcheck_intf.Pre_int) : Quickcheck_intf.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 : Quickcheck_intf.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_intf.Quickcheck_configured with type 'a gen := 'a gen with type 'a shr := 'a shr
include Quickcheck_intf.Quickcheck_config
val default_seed : Quickcheck_intf.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 : Quickcheck_intf.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:Quickcheck_intf.seed -> 'a gen -> 'a

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

val iter : ?seed:Quickcheck_intf.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:Quickcheck_intf.seed -> ?trials:int -> ?attempts:int -> ?shrinker:'a shr -> ?shrink_attempts:Quickcheck_intf.shrink_attempts -> ?probability_threshold_to_remember_choice:float -> ?sexp_of:('a -> Quickcheck_intf.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:Quickcheck_intf.seed -> ?trials:int -> ?attempts:int -> ?probability_threshold_to_remember_choice:float -> ?sexp_of:('a -> Quickcheck_intf.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:Quickcheck_intf.seed -> ?trials:int -> ?attempts:int -> ?probability_threshold_to_remember_choice:float -> ?sexp_of:('a -> Quickcheck_intf.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:Quickcheck_intf.seed -> ?probability_threshold_to_remember_choice:float -> 'a gen -> 'a Sequence.t

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

val random_state_of_seed : Quickcheck_intf.seed -> 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.