module type Quickcheck = sig
.. end
module Generator: module type of struct include Quickcheck_generator end
module Observer: module type of struct include Quickcheck_observer end
include Quickcheck_intf.Quickcheck_config
val random_value : ?seed:Quickcheck_intf.seed -> 'a Generator.t -> 'a
random_value ~seed gen
produces a single value chosen from gen
using seed
.
val iter : ?seed:Quickcheck_intf.seed ->
?trials:int ->
?attempts:int ->
'a Generator.t -> 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 ->
?sexp_of:('a -> Sexplib.Sexp.t) ->
?examples:'a list ->
'a Generator.t -> 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.
val test_can_generate : ?seed:Quickcheck_intf.seed ->
?trials:int ->
?attempts:int ->
?sexp_of:('a -> Sexplib.Sexp.t) ->
'a Generator.t -> f:('a -> bool) -> unit
test_can_generate ~seed ~trials ~attempts ~sexp_of gen ~f
is useful for testing
Generator.t
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 ->
?sexp_of:('a -> Sexplib.Sexp.t) ->
'a Generator.t ->
by:[ `Compare of 'a -> 'a -> int | `Equal of 'a -> 'a -> bool ] -> unit
test_no_duplicates ~seed ~trials ~attempts ~sexp_of gen ~by
is useful for testing
Generator.t
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 ->
'a Generator.t -> '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.