Skip to content

OneOfArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\OneOfArbitrary

ClassPackage: property-testing-coreSourceVersion: 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

php
__construct(
    \Arbitrary\TValue $values,
)
ParameterTypeDefaultDescription
$valuesArbitrary\TValuerequired

Methods

generate()

php
generate(Random $random): Shrinkable

Produce 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.