OneOfArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\OneOfArbitrary
Class — Package: property-testing-core — Source — Version: v0.1.0-12-g86ead85
Implements: ArbitraryInterface
Type parameters:
TValue of mixed = mixed
Picks a value uniformly at random from a fixed set.
Values are used verbatim (they are not arbitraries). Earlier values are considered "smaller": a failing value shrinks through the distinct values listed before it, so put simpler values first. Because the index strictly decreases on every step, shrinking terminates even when several values keep failing. Use this for enumerations and small tagged unions.
Constructor
__construct(
\Arbitrary\TValue $values,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$values | Arbitrary\TValue | required |
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.