Skip to content

ArbitraryInterface ​

Rasuvaeff\PropertyTesting\ArbitraryInterface

Interface — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2

Implemented by: Arbitrary\ArrayArbitrary, Arbitrary\BoolArbitrary, Arbitrary\BytesArbitrary, Arbitrary\CharsetStringArbitrary, Arbitrary\ClassArbitrary, Arbitrary\CommandSequenceArbitrary, Arbitrary\CompositeArbitrary, Arbitrary\ConstantArbitrary, Arbitrary\DateTimeArbitrary, Arbitrary\DictionaryArbitrary, Arbitrary\EdgeCasedArbitrary, Arbitrary\FilteredArbitrary, Arbitrary\FlatMappedArbitrary, Arbitrary\FloatArbitrary, Arbitrary\FrequencyArbitrary, Arbitrary\IntArbitrary, Arbitrary\MappedArbitrary, Arbitrary\NullableArbitrary, Arbitrary\OneOfArbitrary, Arbitrary\RandomEngineArbitrary, Arbitrary\RecordArbitrary, Arbitrary\StringArbitrary, Arbitrary\SubsetArbitrary, Arbitrary\SwarmArbitrary, Arbitrary\TupleArbitrary, Arbitrary\UniqueArrayArbitrary, Arbitrary\UuidArbitrary, Enumerable, Internal\LeafFallbackArbitrary, Swarmable

Type parameters:

  • TValue of mixed = mixed The type of the generated value

Describes a space of random values with integrated shrinking.

An arbitrary produces a Shrinkable via generate(): the generated value together with a lazy tree of smaller candidates, each carrying its own subtree. The property runner reads the value, and on a failure descends through the tree, accepting the first candidate that still fails, until no smaller value fails — yielding a minimal counterexample.

Because shrink candidates are attached at generation time, combinators such as Gen::map() and Gen::flatMap() shrink in the source domain and re-apply their transformation; implementations never need to invert a transformed value.

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.