README

moonbitlang/quickcheck/property does not have a README file

#
Expected

Re-export Expected from internal/state so lower-level property runners can spell run expectations without importing driver internals.

#
Testable

pub(open) trait Testable {
fn property(Self) -> Property
}

Anything that can be handed to a QuickCheck-style driver.

Implementors turn themselves into a Property, which a driver then evaluates. Built-in instances exist for Bool, Unit, results, optional values, generators, and the Arrow wrappers.
impl Testable for Unit
impl Testable for Bool
impl Testable for Option[P]
impl Testable for Result[P, E]
impl Testable for Gen[P]

#
Arrow

pub(all) struct Arrow[A, B]((A) -> B)

Arrow[A, B] is a newtype wrapper around a pure, total function (A) -> B. Wrapping is what lets the package implement Testable for generated inputs; MoonBit does not allow implementing a trait directly on the bare function type (A) -> B.

#
ArrowAsync

pub(all) struct ArrowAsync[A, B](async (A) -> B)

Same role as Arrow, but the wrapped function is async. The type is reserved for async property testing; no Testable impl is wired up yet.

#
ArrowError

pub(all) struct ArrowError[A, B]((A) -> B raise)

Same role as Arrow, but the wrapped function may raise an error. A raised error is converted into a failing property result.
impl Testable for ArrowError[A, P]

#
Discard

type Discard derive(Default)

A property that discards the current test case.
impl Testable for Discard

#
Property

type Property

The shape every Testable collapses to before a driver runs it: a generator of a shrink tree of per-run outcomes.

Property wraps @gen.Gen[@rose.Rose[SingleResult]], keeping the representation opaque while exposing controlled execution helpers.

#
Property::callback

Method form of callback, useful for chaining property decorators.

#
Property::classify

fn Property::classify(self : Property, cond : Bool, s : String) -> Property

Method form of classify, useful for chaining property decorators.

#
Property::collect

fn[T : Show] Property::collect(self : Property, t : T) -> Property

Method form of collect, useful for chaining property decorators.

#
Property::counterexample

fn Property::counterexample(self : Property, s : String) -> Property

Method form of counterexample, useful for chaining diagnostics.

#
Property::filter

fn Property::filter(self : Property, cond : Bool) -> Property

Method form of filter, useful for chaining property decorators.

#
Property::if_fail

fn Property::if_fail(self : Property, f : () -> Unit) -> Property

Method form of if_fail, useful for chaining property decorators.

#
Property::label

fn Property::label(self : Property, s : String) -> Property

Method form of label, useful for chaining property decorators.

#
Property::map_size

fn Property::map_size(self : Property, f : (Int) -> Int) -> Property

Method form of map_size, useful for chaining property decorators.

#
Property::run

Evaluate a Property with an explicit size and random state. This is the controlled representation boundary used by drivers.

#
callback

Attach a post-test or post-final-failure callback to p.

#
classify

fn[P : Testable] classify(p : P, cond : Bool, s : String) -> Property

Classifies a test case based on a condition.

#
collect

fn[P : Testable, T : Show] collect(p : P, t : T) -> Property

Attaches a rendered value as a label to a test case.

#
counterexample

fn[P : Testable] counterexample(p : P, s : String) -> Property

Adds a string to the counterexample if the property fails.

#
filter

fn[P : Testable] filter(p : P, cond : Bool) -> Property

Filters a property based on a condition.

#
forall

Run with an explicit generator.

#
forall_shrink

fn[T : Testable, A :
Debug
] forall_shrink(gen :
Gen
[A], shrinker : (A) -> Iter[A], f : (A) -> T) -> Property

Run a property with an explicit generator and shrinker.

#
if_fail

fn[P : Testable] if_fail(p : P, f : () -> Unit) -> Property

Adds a callback that is called if the property fails.

#
label

fn[P : Testable] label(p : P, s : String) -> Property

Attaches a label to a test case.

#
map_size

fn[P : Testable] map_size(p : P, f : (Int) -> Int) -> Property

Adjust the size parameter before running p. Equivalent to Gen::scale(f) but lifted to the Testable level.

#
property

fn[P : Testable] property(prop : P) -> Property

Lift any Testable value to a chainable Property.

#
shrinking

fn[P : Testable, T] shrinking(shrinker : (T) -> Iter[T], x0 : T, pf : (T) -> P) -> Property

Manually drive shrinking with a user-supplied shrinker and starting value.

#
with_run_options

fn[P : Testable] with_run_options(prop : P, expect :
Expected
, abort : Bool) -> Property

Attach driver run options to every result produced by prop. Driver packages use this instead of reaching into Property's representation directly.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io