std.property - ZZ
Seeded generators + shrinking for property-based tests. Pure ZZ — no engine support needed. Values derive from (seed, index) pairs, so a failing seed replays the exact same cases. check/for_all_int abort with the seed and the shrunk minimal case.
import std.propertyPurpose
Section titled “Purpose”std.property lets you write property-based tests: generators produce values from (seed, index) pairs, shrinkers reduce failing cases, and check asserts a property over generated inputs. Because values derive from (seed, index), a failing seed deterministically replays — ideal for CI flake-hunting.
Quickstart
Section titled “Quickstart”import std.property
func gen_small(seed: int, i: int) -> int { return property.int_in(seed, i, 0, 10)}
func small(x: int) -> bool { return x < 100}
property.check(gen_small, property.shrink_int, small, 200, 7)property.for_all_int(0, 10, small, 200, 7)Production patterns
Section titled “Production patterns”import std.property
@testfunc test_roundtrip() { gen := |seed: int, i: int| -> str { return property.alpha_str(seed, i, 5) } prop := |s: str| -> bool { return len(s) == 5 } property.check(gen, property.shrink_str, prop, 500, 42)}API reference
Section titled “API reference”14 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.
See also
Section titled “See also”std.json— Parse, stringify and read individual values out of JSON.std.map— Pure dictionary helpers over plain maps: lookup, merge and keys.std.set— Arrays with uniqueness: membership, union, intersection and difference.std.dec— Exact decimal arithmetic carried as strings, so money never becomes a float.std.csv— An RFC 4180 subset: read rows, write rows, handle quotes and commas.
Full index: API reference · Standard library