prop_test.nx
buildroot/runtime/prop_test.nx
about
prop_test.nx -- property-based testing infrastructure.
Verify that a property holds across a LARGE random sample of
inputs instead of enumerating hand-picked cases. Catches bugs
that manual test cases miss. Inspired by QuickCheck (Haskell,
2000), Hypothesis (Python), proptest (Rust).
Pattern:
1. Define a property P(x) that should be true for all x of
some type T.
2. Write a generator that produces random T values from a
seeded PRNG.
3. Run P(gen()) for N iterations (default 1000).
4. On failure, record the first counter-example + shrink it
to a minimal case.
This scaffold ships the GENERATOR + RUNNER primitives. Each
property test lives in its own .nx file (see prop_*_test.nx).
Reference: Claessen & Hughes 2000 "QuickCheck: A Lightweight
Tool for Random Testing of Haskell Programs"; MacIver 2019
"Hypothesis: A new approach to property-based testing"
(particularly the shrinking algorithm).
dependencies 2 imports · 2 importers
imports: syscalls.nxnx_assert.nx
imported by: prop_lex_number_test.nxprop_nxtask_store_test.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 35 | struct PropGen { |
consts
| 41 | const PROP_GEN_BYTES: i64 = 32 |
functions
| 43 | func prop_gen_new(seed: i64) -> *PropGen { |
| 61 | func prop_gen_i64(g: *PropGen) -> i64 { |
| 72 | func prop_gen_range(g: *PropGen, lo: i64, hi: i64) -> i64 { |
| 86 | func prop_gen_small(g: *PropGen) -> i64 {
calls 1: prop_gen_i64 |
| 95 | func prop_gen_bytes(g: *PropGen, buf: *u8, n: i64) -> i64 { |
| 106 | func prop_gen_printable(g: *PropGen) -> i64 { |
| 128 | func prop_report(g: *PropGen, tag: *u8) -> i64 { |
| 147 | func main() -> i64 { |