Draw
Rasuvaeff\PropertyTesting\Draw
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
The draw seam a Gen::composite() body receives: every value the body needs comes through draw(), and each draw is one position on a tape the composite replays and shrinks — the same model as in-body Gen::draw(), scoped to one generated value instead of a whole run.
Gen::composite(static fn (Draw $d): Interval => new Interval( $min = $d->draw(Gen::datetime()), $d->draw(Gen::datetime(min: $min)), ));
Instances are handed to the body by the engine; there is nothing to construct by hand.
Constructor
__construct(
int $seed,
\Runner\EdgeCases $edgeCases,
list<\Shrinkable> $tape = [],
)| Parameter | Type | Default | Description |
|---|---|---|---|
$seed | int | required | The composite's captured seed; each position derives its own stream from it. |
$edgeCases | Runner\EdgeCases | required | The boundary-value mode of the run, carried into every position's stream. |
$tape | list<\Shrinkable> | [] | Nodes to replay by position; draws past its end generate anew. |
Methods
draw()
draw(\ArbitraryInterface<\T> $arbitrary): mixedOne value from $arbitrary. Replayed from the tape while it lasts — served as recorded, not re-validated against $arbitrary — and past its end generated from a stream of this position's own: the same position draws from the same stream on every execution, so a draw that follows a shrunk one comes back unchanged when its generator did not change, and is re-drawn through the new range when it did.
$arbitrary— What to draw when the tape has no node for this position.
recorded()
recorded(): arrayThe nodes the body actually used, in order.