code wiki / (root) / proptest.nx

proptest.nx

buildroot/runtime/proptest.nx

4312 B121 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

syscalls.nx xoshiro.nx proptest.nx

imports: syscalls.nxxoshiro.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 xoshiro_new xoshiro_seed xs_splitmix prop_gen_nonneg xoshiro_bounded xoshiro_next xs_rotl nx_bits_rotl64 prop_gen_small xoshiro_bounded ↻ prop_run_i64

structs

36struct PropConfig {

consts

32const PT_OK: i64 = 0
33const PT_ERR_FAIL: i64 = -1
34const PT_ERR_TIMEOUT: i64 = -2

functions

43func prop_config_new() -> *PropConfig {
called by 1: main
58func prop_shrink_i64(failing: i64, cfg: *PropConfig,
70func prop_run_i64(cfg: *PropConfig,
called by 1: main
87func prop_gen_i64(rng: *Xoshiro, cfg: *PropConfig) -> i64 {
calls 1: xoshiro_bounded
94func prop_gen_nonneg(rng: *Xoshiro, cfg: *PropConfig) -> i64 {
called by 1: main calls 1: xoshiro_bounded
99func prop_gen_small(rng: *Xoshiro, cfg: *PropConfig) -> i64 {
called by 1: main calls 1: xoshiro_bounded
104func main() -> i64 {