package windtrap
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=2241b294b24ed5d56ea8b834d296e6fabc5dbdd924a89f51c14b00da66c50a25
sha512=c6cf83028bb09d0f2afeb38fce6825620873a6bbeff4b5b77e928bc2fc69262d49fe341961cba2b451c9dc9bd0df414f06bb73020c7131b125c6abd85c6bc5dd
doc/windtrap.prop/Windtrap_prop/Prop/index.html
Module Windtrap_prop.PropSource
Property 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.
Configuration
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.
*)Nonereads theWINDTRAP_SEEDenvironment 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.
Results
A coverage requirement that was not met.
type result = | Success of {}(*Property passed for
*)countinputs, discardingdiscardedcases.| 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_genbeforecounttests passed.
Result of running a property test.
Running Properties
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.