Manuscript Documentation
v2026.12.0

@std/test/property.ms#

Import each required symbol with import Name from "@std/test/property.ms".

Drawn Type#

A generated value and the source after the draws that made it.

Manuscript
type Drawn[T] {
    value T
    source Source
}

Drawn.source#

The source to continue drawing from; draws already made are recorded in it.

Manuscript
source Source

Drawn.value#

The value a generator built from the draws it read.

Manuscript
value T

Gen Type#

A generator of T values. Build one with the functions in this module and run it with check.

Manuscript
type Gen[T] {
    make fn(move Source) Drawn[T]
}

Gen.make#

Reads draws from the source and builds a value.

Manuscript
make fn(move Source) Drawn[T]

Gen.filter#

Keeps only the values for which keep is true. After 50 consecutive rejections the case is marked invalid and discarded.

Manuscript
fn filter(move keep fn(T) Bool) Gen[T]

Gen.flat_map#

Generates a value, then generates again with the generator that next returns for it (dependent generation).

Manuscript
fn flat_map[B](move next fn(T) Gen[B]) Gen[B]

Gen.map#

Returns a generator that applies transform to every generated value.

Manuscript
fn map[B](move transform fn(T) B) Gen[B]

Gen.zip#

Generates one value from this generator and one from other, and combines them with combine.

Manuscript
fn zip[B, C](other Gen[B], move combine fn(T, B) C) Gen[C]

PropertyOptions Type#

Settings for check: how many cases to generate (default 100) and an optional fixed seed that replays a failing run.

Manuscript
type PropertyOptions {
    runs Int = 100
    seed Int? = null
}

PropertyOptions.runs#

Number of generated cases (default 100).

Manuscript
runs Int = 100

PropertyOptions.seed#

Fixes the random seed to replay a failure; null picks a fresh seed.

Manuscript
seed Int? = null

Settings Type#

Run settings. ms test fills them from --runs, --seed and --fuzz through environment variables.

Manuscript
type Settings {
    runs Int
    fuzz_milliseconds Int
    seed Int? = null
}

Settings.fuzz_milliseconds#

Time budget in milliseconds; above 0, cases run until it expires instead of stopping at runs.

Manuscript
fuzz_milliseconds Int

Settings.runs#

Cases to run when not fuzzing.

Manuscript
runs Int

Settings.seed#

First case seed, or null for a random one that failures report.

Manuscript
seed Int? = null

Source Type#

The recorded stream of draws that a generator reads. Create one with source; generators call draw.

Manuscript
type Source {
    choices List[Int]
    pos Int
    state Int
    fresh Bool
    invalid Bool
}

Source.choices#

Every draw so far, in order, each within its bound.

Manuscript
choices List[Int]

Source.fresh#

True while generating new input, false while replaying a recorded prefix (missing draws read as 0).

Manuscript
fresh Bool

Source.invalid#

Set by filter when it cannot satisfy its predicate; check discards such cases instead of running them.

Manuscript
invalid Bool

Source.pos#

How many entries of choices the current generation has read.

Manuscript
pos Int

Source.state#

Pseudo-random state; fresh draws past the recorded prefix come from it.

Manuscript
state Int

Source.next_bits#

Internal: returns the next 64 random bits as a signed Int (SplitMix64).

Manuscript
var fn next_bits() Int

bools Function#

Generates true and false, shrinking toward false.

Manuscript
fn bools() Gen[Bool] { ... }

check Function#

Runs property on generated values and fails, naming a shrunk counterexample, when it returns an error. A property returns a Result, like a test assertion; write it with expect_* calls and ?. A fault (panic) inside a property counts as a failing case and shrinks like an error.

Manuscript
fn check[T](name String, gen Gen[T], property fn(T) Result[Void, Error], options PropertyOptions = PropertyOptions()) Result[Void, Error] { ... }

constant Function#

Always generates a copy of value, consuming no draws, so it never shrinks.

Manuscript
fn constant[T Clonable](value T) Gen[T] { ... }

draw Function#

Draws an integer from 0 through max, both included, and returns it with the advanced source; max must not be negative. Fresh draws favor the two ends. Shrinking lowers each draw toward 0, so 0 is the simplest outcome.

Manuscript
fn draw(move source Source, max Int) Drawn[Int] { ... }

element_of Function#

Generates one of values, shrinking toward the first. values must not be empty.

Manuscript
fn element_of[T Clonable](values List[T]) Gen[T] { ... }

floats Function#

Generates floats from low through high at 2^-53 resolution, shrinking toward low. The bounds may be as far apart as the largest finite Floats.

Manuscript
fn floats(low Float, high Float) Gen[Float] { ... }

ints Function#

Generates integers from low through high, both included, shrinking toward the value nearest 0. When the range spans 0, a sign draw comes first and the magnitude after it. high - low must fit in Int.

Manuscript
fn ints(low Int, high Int) Gen[Int] { ... }

lists Function#

Generates lists of min_length through max_length elements, shrinking toward fewer and simpler elements.

Manuscript
fn lists[T](move gen Gen[T], min_length Int = 0, max_length Int = 20) Gen[List[T]] { ... }

one_of Function#

Generates by picking one of gens, shrinking toward the first. gens must not be empty.

Manuscript
fn one_of[T](gens List[Gen[T]]) Gen[T] { ... }

optionals Function#

Generates a value or null, shrinking toward null.

Manuscript
fn optionals[T](move gen Gen[T]) Gen[T?] { ... }

pairs Function#

Generates a 2-element Pair.

Manuscript
fn pairs[A, B](move first Gen[A], move second Gen[B]) Gen[Pair[A, B]] { ... }

settings Function#

Returns the run settings, with runs as the default case count, after applying the ms test flag overrides (MS_TEST_RUNS, MS_TEST_SEED, MS_TEST_FUZZ_MS).

Manuscript
fn settings(runs Int = 100) Settings { ... }

source Function#

Returns a source that generates fresh input from seed.

Manuscript
fn source(seed Int) Source { ... }

strings Function#

Generates strings of up to max_length characters drawn from alphabet, shrinking toward shorter text of its first characters. alphabet must not be empty.

Manuscript
fn strings(alphabet String = "abcdefghijklmnopqrstuvwxyz0123456789 ", max_length Int = 20) Gen[String] { ... }