module Test:sig..end
type 'a cell
A single property test
val fail_report : string -> 'aFail the test with some additional message that will be reported.
val fail_reportf : ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'aFormat version of QCheck.Test.fail_report
val make_cell : ?if_assumptions_fail:[ `Fatal | `Warning ] * float ->
?count:int ->
?long_factor:int ->
?max_gen:int ->
?max_fail:int ->
?small:('a -> int) ->
?name:string -> 'a QCheck.arbitrary -> ('a -> bool) -> 'a cellmake_cell arb prop builds a test that checks property prop on instances
of the generator arb.
if_assumptions_fail : the minimum
fraction of tests that must satisfy the precondition for a success
to be considered valid.
The fraction should be between 0. and 1.
A warning will be emitted otherwise if
the flag is `Warning, the test will be a failure if the flag is `Fatal.
(since 0.10)count : number of test cases to run, counting only
the test cases which satisfy preconditions.long_factor : the factor by which to multiply count, max_gen and
max_fail when running a long test (default: 1).max_gen : maximum number of times the generation function
is called in total to replace inputs that do not satisfy
preconditions (should be >= count).max_fail : maximum number of failures before we stop generating
inputs. This is useful if shrinking takes too much time.small : kept for compatibility reasons; if provided, replaces
the field arbitrary.small.
If there is no shrinking function but there is a small
function, only the smallest failures will be printed.name : the name of the test.val get_arbitrary : 'a cell -> 'a QCheck.arbitrary
val get_law : 'a cell -> 'a -> bool
val get_name : 'a cell -> string
val set_name : 'a cell -> string -> unit
val get_count : 'a cell -> intGet the count of a cell.
val get_long_factor : 'a cell -> intGet the long factor of a cell.
type t =
| |
Test : |
(* | Same as | *) |
val make : ?if_assumptions_fail:[ `Fatal | `Warning ] * float ->
?count:int ->
?long_factor:int ->
?max_gen:int ->
?max_fail:int ->
?small:('a -> int) ->
?name:string -> 'a QCheck.arbitrary -> ('a -> bool) -> tmake arb prop builds a test that checks property prop on instances
of the generator arb.
See QCheck.Test.make_cell for a description of the parameters.
exception Test_fail of string * string list
Exception raised when a test failed, with the list of counter-examples.
Test_fail (name, l) means test name failed on elements of l.
exception Test_error of string * string * exn * string
Exception raised when a test raised an exception e, with
the sample that triggered the exception.
Test_error (name, i, e, st)
means name failed on i with exception e, and st is the
stacktrace (if enabled) or an empty string.
val print_instance : 'a QCheck.arbitrary -> 'a -> string
val print_c_ex : 'a QCheck.arbitrary -> 'a QCheck.TestResult.counter_ex -> string
val print_fail : 'a QCheck.arbitrary ->
string -> 'a QCheck.TestResult.counter_ex list -> string
val print_fail_other : string -> msg:string -> string
val print_error : ?st:string ->
'a QCheck.arbitrary ->
string -> 'a QCheck.TestResult.counter_ex * exn -> string
val print_test_fail : string -> string list -> string
val print_test_error : string -> string -> exn -> string -> string
val print_collect : (string, int) Stdlib.Hashtbl.t -> stringPrint "collect" results.
val print_stat : 'a QCheck.stat * (int, int) Stdlib.Hashtbl.t -> stringPrint statistics.
val check_result : 'a cell -> 'a QCheck.TestResult.t -> unitcheck_result cell res checks that res is Ok _, and returns unit.
Otherwise, it raises some exception.
Test_error if res = Error _Test_error if res = Failed _type res =
| |
Success |
| |
Failure |
| |
FalseAssumption |
| |
Error of |
type 'a event =
| |
Generating |
| |
Collecting of |
| |
Testing of |
| |
Shrunk of |
| |
Shrinking of |
type'ahandler =string -> 'a cell -> 'a event -> unit
Handler executed after each event during testing of an instance.
type'astep =string -> 'a cell -> 'a -> res -> unit
Callback executed after each instance of a test has been run. The callback is given the instance tested, and the current results of the test.
type'acallback =string -> 'a cell -> 'a QCheck.TestResult.t -> unit
Callback executed after each test has been run.
f name cell res means test cell, named name, gave res.
val check_cell : ?long:bool ->
?call:'a callback ->
?step:'a step ->
?handler:'a handler ->
?rand:Stdlib.Random.State.t -> 'a cell -> 'a QCheck.TestResult.tcheck_cell ~long ~rand test generates up to count random
values of type 'a using arbitrary and the random state st. The
predicate law is called on them and if it returns false or raises an
exception then we have a counter-example for the law.
long : if true then multiply the number of instances to generate
by the cell's long_factor.call : function called on each test case, with the result.step : function called on each instance of the test case, with the result.val check_cell_exn : ?long:bool ->
?call:'a callback ->
?step:'a step ->
?rand:Stdlib.Random.State.t -> 'a cell -> unitSame as QCheck.Test.check_cell but calls QCheck.Test.check_result on the result.
Test_error if res = Error _Test_error if res = Failed _val check_exn : ?long:bool -> ?rand:Stdlib.Random.State.t -> t -> unitChecks the property against some test cases, and calls QCheck.Test.check_result,
which might raise an exception in case of failure.
Test_error if res = Error _Test_error if res = Failed _