RuleSequence
Rasuvaeff\PropertyTesting\StateMachine\RuleSequence
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implements: Stringable
A generated sequence of RuleSteps over a rule-based machine — what Gen::rules() produces and the property body runs against a machine it builds:
#[Property(runs: 200)] public function queueBehavesLikeAList(RuleSequence $sequence): void { $sequence->run(static fn (): QueueMachine => new QueueMachine(new Queue())); }
The factory is handed to StateMachine\run() rather than kept in the value — the split StateMachine\StateMachine::check() makes — so the sequence stays a plain value: it renders as the trace, serializes inside a result, and never carries a closure into the corpus.
StateMachine\run() builds a fresh machine every time, so shrink trials never see state a previous trial left behind, checks the invariants once, then walks the steps: a step whose StateMachine\Precondition is false in the machine's current state is skipped, every other step runs its rule and then every invariant. The first exception ends the run and falsifies the property.
Constructor
__construct(
list<\StateMachine\RuleStep> $steps,
list<non-empty-string> $invariants = [],
)| Parameter | Type | Default | Description |
|---|---|---|---|
$steps | list<\StateMachine\RuleStep> | required | The steps, in the order they were generated. |
$invariants | list<non-empty-string> | [] | The invariant methods, checked before the first step. |
Methods
run()
run(callable $factory): voidExecute the sequence against the machine $factory builds.
$factory— A fresh machine, system under test included.
__toString()
__toString(): stringThe trace: every step as a call, in order.