Windtrap_prop.PropSourceProperty runner and configuration.
Property-based testing runner.
This module provides the core property checking logic. It generates random inputs, tests properties, and shrinks failing cases to find minimal counterexamples.
assume b discards the current test case if b is false. Prefer constrained generators when possible, as excessive discarding causes the test to return result.Gave_up.
reject () unconditionally discards the current test case.
collect label records label for the current generated case.
Collected labels are reported as a distribution. A label is counted at most once per generated case, even if collect is called multiple times.
classify label cond is if cond then collect label.
cover ~label ~at_least cond declares a coverage requirement and records a hit for label when cond is true.
Coverage is checked over successful (non-discarded) cases. The property fails with result.Coverage_failed when label appears in less than at_least percent of successful cases.
type config = {count : int;Number of successful tests required. Default: 100.
*)max_gen : int;Maximum generation attempts (including discards). Default: 300.
*)max_shrink : int;Maximum shrink steps. Default: 100.
*)seed : int option;Random seed. None reads the WINDTRAP_SEED environment variable, falling back to a random seed.
}Property test configuration.
Default configuration: 100 tests, 300 max gen, 100 max shrink, no fixed seed.
set_default_seed seed sets a global default seed used when config.seed is None and WINDTRAP_SEED is not set. Called by Windtrap.run to propagate the CLI --seed flag to property tests.
set_default_count count sets a global default test count used when no explicit config.count override is provided. Called by Windtrap.run to propagate the CLI --prop-count flag.
A coverage requirement that was not met.
type result = | Success of {}Property passed for count inputs, discarding discarded cases.
| Failed of {count : int;discarded : int;seed : int;counterexample : string;shrunk_counterexample : string;shrink_steps : int;}Property failed. Shows original and shrunk counterexamples.
*)| Error of {}Property raised an unexpected exception.
*)| Coverage_failed of {count : int;discarded : int;seed : int;missing : coverage_issue list;collected : (string * int) list;}Property predicate passed, but one or more coverage requirements were not met.
*)| Gave_up of {}Generation attempts reached max_gen before count tests passed.
Result of running a property test.
val check :
?config:config ->
?rand:Random.State.t ->
'a Arbitrary.t ->
('a -> bool) ->
resultcheck arb prop tests that prop holds for all values from arb.
On failure, attempts to shrink the counterexample to find a minimal failing case. Returns detailed result with counterexample and shrink info.