Type-safe equality witnesses for assertions and property testing.
A testable bundles pretty-printing, equality, and optionally a random generator for a given type. Built-in testables are provided for primitives and common containers. Compose them with pair, list, option, etc.
Container testables (list, array, string) produce highlighted diffs on assertion failure, pinpointing changed elements.
Equality function for assertions. Defaults to structural equality (=). For property-only testables (used with Windtrap.prop but not Windtrap.equal), this can be omitted.
parametergen
Random generator for property-based testing with Windtrap.prop.
parametercheck
Custom comparison that produces structured diff output on failure. When provided, assertions use check instead of equal.
with_gen gen t returns a copy of t that uses gen as its random generator. Useful when the default generator produces values outside the domain of the property under test.
(* int with bounded range to avoid overflow in arithmetic *)
let safe_int = Testable.(with_gen Gen.small_int int)
Like int but uses Windtrap_prop.Gen.small_int, which generates integers in [-10_000, 10_000]. Useful for properties involving arithmetic that would overflow with full-range integers.
float eps creates a testable with absolute tolerance eps. Two floats a and b are equal when |a - b| <= eps. NaN equals NaN for testing purposes.
Sourceval float_rel : rel:float ->abs:float ->float t
float_rel ~rel ~abs creates a testable with both relative and absolute tolerance. Two floats a and b are equal when their difference is within abs or within rel * max(|a|, |b|). NaN equals NaN.