EdgeCasedArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\EdgeCasedArbitrary
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implements: Enumerable, ArbitraryInterface
Type parameters:
T of mixed = mixed
A delegate arbitrary with author-supplied boundary values: one draw in self::BIAS_DENOMINATOR is one of the edge values instead of what the delegate generates, and every value the delegate does generate shrinks through the edge values first, in the order they were listed, before its own tree.
The bias is scoped to this generator and explicit, so it ignores the run-wide Runner\EdgeCases mode: an opt-in beats a global opt-out. The roll consumes the run's randomness like the built-in boundary bias does, so the delegate's own sequence is unchanged for a seed — only what this wrapper selects is new.
An edge value drawn outright shrinks to the edge values listed before it, so the first one is the most-preferred minimum. A candidate equal (===) to the value it would replace is skipped: no candidate equals its parent.
Constructor
__construct(
\ArbitraryInterface<\Arbitrary\T> $inner,
list<\Arbitrary\T> $edgeCases,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$inner | \ArbitraryInterface<\Arbitrary\T> | required | The delegate that generates everything but the edge draws. |
$edgeCases | list<\Arbitrary\T> | required | The boundary values, most-preferred minimum first; at least one. |
Methods
generate()
generate(\Random $random): ShrinkableProduce one random value from this arbitrary's space, together with its shrink tree. Candidates must be ordered most aggressive first (typically toward a zero/empty/identity element) and every branch of the tree must be finite, so shrinking terminates.
Documentation inherited from ArbitraryInterface.
$random— The run's stream: one roll for edge-versus-delegate, then the delegate's draws.
domainSize()
domainSize(): ?intThe delegate's domain: the edge values are taken as members of it.
enumerate()
enumerate(): iterableEvery value of the domain, once each, as a shrinkable node with the same tree generate() would give it, in a fixed order that does not depend on any seed. Only meaningful when domainSize() is not null; an implementation may throw otherwise.
Documentation inherited from Enumerable.
Throws:
LogicException— When the delegate has no finite domain (\Rasuvaeff\PropertyTesting\Arbitrary\domainSize() is null).