March Docs

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
    )
  end

Seed sources (highest priority first):

  1. CheckConfig.seed passed to Check.all_with
  2. MARCH_PROP_SEED environment variable (set by forge test --seed=N)
  3. current Unix time

Types

typeCheckConfigCheckConfig = { num_runs : Int, seed : Option(Int),#

Functions

fnallall(g, prop)#

Run a property with default config (100 runs). Panics with a formatted counterexample on failure, which the test runner catches and reports.

fnall_withall_with(g, prop, config : CheckConfig)#

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) })
fndefault_configdefault_config() : CheckConfig#

Sensible defaults: 100 runs, size grows to 100, up to 1000 shrink steps, seed picked from env or clock.

fntry_proptry_prop(prop : a -> Bool, value : a) : Result(Bool, String)#

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.)