package windtrap

  1. Overview
  2. Docs

Module Windtrap_propSource

Property-based testing for Windtrap.

This library provides generators and a property runner for property-based testing. Use with the main Windtrap library for full test integration.

Quick Start

With the main Windtrap library, use Testable values directly for property testing:

  open Windtrap

  let () =
    run "Properties"
      [
        prop "reverse is involutive"
          Testable.(list int)
          (fun l -> List.rev (List.rev l) = l);
        prop "append length"
          Testable.(pair (list int) (list int))
          (fun (l1, l2) ->
            List.length (l1 @ l2) = List.length l1 + List.length l2);
      ]
Sourcemodule Gen : sig ... end

Random value generators with integrated shrinking.

Sourcemodule Arbitrary : sig ... end

Arbitrary values: generators bundled with printers. Used internally by Prop.check. Most users should use Testable values with Windtrap.prop instead.

Sourcemodule Prop : sig ... end

Property runner and configuration.

Sourceval assume : bool -> unit

assume b discards the current test case if b is false. Prefer constrained generators when possible, as excessive discarding causes the test to give up.

Sourceval reject : unit -> 'a

reject () unconditionally discards the current test case.

Sourceval collect : string -> unit

collect label records label for the current property case.

Sourceval classify : string -> bool -> unit

classify label cond records label when cond is true.

Sourceval cover : label:string -> at_least:float -> bool -> unit

cover ~label ~at_least cond declares and checks a coverage requirement for label, and records a hit when cond is true.