code wiki / (root) / nx_proptest.nx

nx_proptest.nx

buildroot/runtime/nx_proptest.nx

4489 B128 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

proptest.nx -- property-based testing. EFFICIENCY_ROADMAP ยง5.1. Runtime: sample N random inputs, run a property on each, shrink failing input to minimal example. Quickcheck / Hypothesis / proptest equivalent. Property-based tests complement unit tests: where a unit test says "f(5) = 25", a property test says "forall n, f(n) >= 0 AND n*n >= n for n>=1". Covers input space unit tests miss. Usage shape (pseudocode until parse.nx grows lambdas): let cfg: *PropConfig = prop_config_new() cfg.n_trials = 100 let rc: i64 = prop_run(cfg, "divides_correctly", gen_i64, check_divide) if rc != 0 { /* failure */ } Generators + check functions are plain `func` values today; phase B introduces closure syntax so properties are one-liners. Invariants: PT1 Every failing trial is reported + shrunk before return. PT2 RNG state is DETERMINISTIC given the same seed so reproduction is trivial. PT3 Max trials cap respected; partial success (N-1 of N) counts as success + reports the failing seed.

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_xoshiro.nx nx_proptest.nx

imports: nx_syscalls.nxnx_xoshiro.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main prop_config_new sys_mmap xoshiro_new sys_mmap ↻ xoshiro_seed sys_mmap ↻ xs_splitmix prop_gen_nonneg xoshiro_bounded xoshiro_next xs_rotl nx_bits_rotl64 prop_gen_small xoshiro_bounded ↻ prop_run_i64

structs

43struct PropConfig

consts

37const PT_MAGIC_1024: i64 = 1024
39const PT_OK: i64 = 0
40const PT_ERR_FAIL: i64 = -1
41const PT_ERR_TIMEOUT: i64 = -2

functions

50func prop_config_new() -> *PropConfig
called by 1: main calls 1: sys_mmap
65func prop_shrink_i64(failing: i64, cfg: *PropConfig,
77func prop_run_i64(cfg: *PropConfig,
called by 1: main
94func prop_gen_i64(rng: *Xoshiro, cfg: *PropConfig) -> i64
calls 1: xoshiro_bounded
101func prop_gen_nonneg(rng: *Xoshiro, cfg: *PropConfig) -> i64
called by 1: main calls 1: xoshiro_bounded
106func prop_gen_small(rng: *Xoshiro, cfg: *PropConfig) -> i64
called by 1: main calls 1: xoshiro_bounded
111func main() -> i64