package qcheck-core

  1. Overview
  2. Docs

Module QCheck.TestSource

Module related to individual tests.

  • since 0.18 most of it moved to {!QCheck2},

and the type 'a cell was made a private implementation detail.

Sourcetype res = QCheck2.Test.res =
  1. | Success
  2. | Failure
  3. | FalseAssumption
  4. | Error of exn * string
Sourcetype 'a event = 'a QCheck2.Test.event =
  1. | Generating
  2. | Collecting of 'a
  3. | Testing of 'a
  4. | Shrunk of int * 'a
  5. | Shrinking of int * int * 'a
Sourcetype 'a cell = 'a QCheck2.Test.cell
Sourcetype 'a handler = 'a QCheck2.Test.handler
Sourcetype 'a step = 'a QCheck2.Test.step
Sourcetype 'a callback = 'a QCheck2.Test.callback
Sourceval fail_report : string -> 'a

Fail the test with some additional message that will be reported.

  • since 0.7
Sourceval fail_reportf : ('a, Format.formatter, unit, 'b) format4 -> 'a

Format version of fail_report

  • since 0.7
Sourceval make_cell : ?if_assumptions_fail:([ `Fatal | `Warning ] * float) -> ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> ('a -> bool) -> 'a cell

make_cell arb prop builds a test that checks property prop on 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 retries

    number of times to retry the tested property while shrinking.

  • parameter long_factor

    the factor by which to multiply count, max_gen and max_fail when running a long test (default: 1).

  • parameter negative

    whether the test is expected not to satisfy the tested property.

  • 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 small function, 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)

Sourceval get_law : 'a cell -> 'a -> bool
Sourceval get_name : _ cell -> string
Sourceval set_name : _ cell -> string -> unit
Sourceval get_count : _ cell -> int

Get the count of a cell.

  • since 0.5.3
Sourceval get_long_factor : _ cell -> int

Get the long factor of a cell.

  • since 0.5.3
Sourceval make : ?if_assumptions_fail:([ `Fatal | `Warning ] * float) -> ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> ('a -> bool) -> t

make arb prop builds a test that checks property prop on instances of the generator arb. See make_cell for a description of the parameters.

Sourceval make_neg : ?if_assumptions_fail:([ `Fatal | `Warning ] * float) -> ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> ('a -> bool) -> t

make_neg arb prop builds a test that checks property prop on instances of the generator arb. The test is considered negative, meaning that it is expected not to satisfy the tested property. This information is recorded in an underlying test cell entry and interpreted suitably by test runners. See make_cell for a description of the parameters.

include module type of QCheck2.Test_exceptions
Sourceexception 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.

Sourceexception 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.

Sourceexception Test_unexpected_success of string

Exception raised when a negative test failed. Test_unexpected_success name means test name failed to find an expected counter example.

Sourceval print_instance : 'a cell -> 'a -> string
Sourceval print_c_ex : 'a cell -> 'a TestResult.counter_ex -> string
Sourceval print_fail : 'a cell -> string -> 'a TestResult.counter_ex list -> string
Sourceval print_fail_other : string -> msg:string -> string
Sourceval print_error : ?st:string -> 'a cell -> string -> ('a TestResult.counter_ex * exn) -> string
Sourceval print_test_fail : string -> string list -> string
Sourceval print_test_error : string -> string -> exn -> string -> string
Sourceval check_cell : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> 'a TestResult.t
Sourceval check_cell_exn : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> unit
Sourceval check_exn : ?long:bool -> ?rand:Random.State.t -> t -> unit
OCaml

Innovation. Community. Security.