Check
Check module: property-test runner with integrated shrinking.
Runs a Gen.Generator(a)-produced value through a user-supplied property function a configurable number of times. When a property fails — whether by returning false, raising an assert failure, or crashing with any other runtime exception — the runner walks the failing input's shrink tree (integrated into the generator per Hedgehog's design) to find a minimal counterexample, then panics with a report that includes the shrunk value, the number of runs, and the seed for replay.
The existing test ... do ... end runner catches the panic and reports the property as a failing test. No compiler changes required beyond the __try_call builtin that catches runtime exceptions.
Typical use:
test "reverse is involution" do
Check.all(Gen.list(Gen.int(-100, 100)), fn xs ->
List.reverse(List.reverse(xs)) == xs
)
endSeed sources (highest priority first):
CheckConfig.seedpassed toCheck.all_withMARCH_PROP_SEEDenvironment variable (set byforge test --seed=N)- current Unix time
Types
Functions
Run a property with default config (100 runs). Panics with a formatted counterexample on failure, which the test runner catches and reports.
Run a property with explicit config. Use to override run count, seed, or shrink budget. Example:
Check.all_with(gen, prop, { Check.default_config() with seed: Some(42) })Sensible defaults: 100 runs, size grows to 100, up to 1000 shrink steps, seed picked from env or clock.
Run a property with a value, catching any runtime failure. Returns: Ok(true) — property held Ok(false) — property returned false Err(msg) — property raised (assert, panic, match failure, etc.)