Module QCheck.Test
- val fail_report : string -> 'a
- Fail the test with some additional message that will be reported. - since
- 0.7
 
- val fail_reportf : ('a, Format.formatter, unit, 'b) Pervasives.format4 -> 'a
- Format version of - fail_report- since
- 0.7
 
- 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 arbitrary -> ('a -> bool) -> 'a cell
- make_cell arb propbuilds a test that checks property- propon instances of the generator- arb.- parameter name
- the name of the test. 
 - parameter count
- number of test cases to run, counting only the test cases which satisfy preconditions. 
 - parameter long_factor
- the factor by which to multiply count, max_gen and max_fail when running a long test (default: 1). 
 - parameter max_gen
- maximum number of times the generation function is called in total to replace inputs that do not satisfy preconditions (should be >= count). 
 - parameter max_fail
- maximum number of failures before we stop generating inputs. This is useful if shrinking takes too much time. 
 - parameter small
- kept for compatibility reasons; if provided, replaces the field - arbitrary.small. If there is no shrinking function but there is a- smallfunction, only the smallest failures will be printed.
 - parameter 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)
 
- val get_arbitrary : 'a cell -> 'a arbitrary
- val get_law : 'a cell -> 'a -> bool
- val get_name : _ cell -> string
- val set_name : _ cell -> string -> unit
- val get_count : _ cell -> int
- Get the count of a cell. - since
- 0.5.3
 
- val get_long_factor : _ cell -> int
- Get the long factor of a cell. - since
- 0.5.3
 
- type t- =- |- Test : 'a cell -> t- Same as - 'a cell, but masking the type parameter. This allows to put tests on different types in the same list of tests.
- 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 arbitrary -> ('a -> bool) -> t
- make arb propbuilds a test that checks property- propon instances of the generator- arb. See- make_cellfor a description of the parameters.
Running the test
- 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- namefailed 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- namefailed on- iwith exception- e, and- stis the stacktrace (if enabled) or an empty string.
- val print_instance : 'a arbitrary -> 'a -> string
- val print_c_ex : 'a arbitrary -> 'a TestResult.counter_ex -> string
- val print_fail : 'a arbitrary -> string -> 'a TestResult.counter_ex list -> string
- val print_fail_other : string -> msg:string -> string
- val print_error : ?st:string -> 'a arbitrary -> string -> ('a 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) Hashtbl.t -> string
- Print "collect" results. - since
- 0.6
 
- val print_stat : ('a stat * (int, int) Hashtbl.t) -> string
- Print statistics. - since
- 0.6
 
- val check_result : 'a cell -> 'a TestResult.t -> unit
- check_result cell reschecks that- resis- Ok _, and returns unit. Otherwise, it raises some exception.- raises Test_error
- if - res = Error _
 - raises Test_error
- if - res = Failed _
 
- type res- =- |- Success- |- Failure- |- FalseAssumption- |- Error of exn * string
- type 'a event- =- |- Generating- |- Collecting of 'a- |- Testing of 'a- |- Shrunk of int * 'a- |- Shrinking of int * int * 'a
- type 'a handler- = string -> 'a cell -> 'a event -> unit
- Handler executed after each event during testing of an instance. 
- type 'a step- = 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 'a callback- = string -> 'a cell -> 'a TestResult.t -> unit
- Callback executed after each test has been run. - f name cell resmeans test- cell, named- name, gave- res.
- val check_cell : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> 'a TestResult.t
- check_cell ~long ~rand testgenerates up to- countrandom values of type- 'ausing- arbitraryand the random state- st. The predicate- lawis called on them and if it returns- falseor raises an exception then we have a counter-example for the- law.- parameter long
- if - truethen multiply the number of instances to generate by the cell's long_factor.
 - parameter call
- function called on each test case, with the result. 
 - parameter step
- function called on each instance of the test case, with the result. 
 - returns
- the result of the test. 
 
- val check_cell_exn : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?rand:Random.State.t -> 'a cell -> unit
- Same as - check_cellbut calls- check_resulton the result.- raises Test_error
- if - res = Error _
 - raises Test_error
- if - res = Failed _
 
- val check_exn : ?long:bool -> ?rand:Random.State.t -> t -> unit
- Checks the property against some test cases, and calls - check_result, which might raise an exception in case of failure.- raises Test_error
- if - res = Error _
 - raises Test_error
- if - res = Failed _