Up

Module Quickcheck = Async_kernel.Async_quickcheck

Signature

include Async_kernel.Async_quickcheck_intf.Quickcheck_async_configured
include Async_quickcheck_intf.Quickcheck_configured with type 'a gen := 'a Core_kernel.Std.Quickcheck.Generator.t
include Async_quickcheck_intf.Quickcheck_config
val default_seed : Async_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 : Async_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:Async_quickcheck_intf.seed -> 'a gen -> 'a

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

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

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.

val async_test : ?seed:Async_quickcheck_intf.seed -> ?trials:int -> ?sexp_of:('a -> Async_quickcheck_intf.Sexp.t) -> 'a Core_kernel.Std.Quickcheck.Generator.t -> f:('a -> unit Async_kernel.Deferred.t) -> unit Async_kernel.Deferred.t

Like test, but for asynchronous tests.