ArbitraryInterface
Rasuvaeff\PropertyTesting\ArbitraryInterface
Interface — Package: property-testing-core — Source — Version: v0.1.0-12-g86ead85
Implemented by: Arbitrary\ArrayArbitrary, Arbitrary\BoolArbitrary, Arbitrary\BytesArbitrary, Arbitrary\CharsetStringArbitrary, Arbitrary\CommandSequenceArbitrary, Arbitrary\ConstantArbitrary, Arbitrary\DateTimeArbitrary, Arbitrary\DictionaryArbitrary, Arbitrary\FilteredArbitrary, Arbitrary\FlatMappedArbitrary, Arbitrary\FloatArbitrary, Arbitrary\FrequencyArbitrary, Arbitrary\IntArbitrary, Arbitrary\MappedArbitrary, Arbitrary\NullableArbitrary, Arbitrary\OneOfArbitrary, Arbitrary\RecordArbitrary, Arbitrary\StringArbitrary, Arbitrary\SubsetArbitrary, Arbitrary\TupleArbitrary, Arbitrary\UniqueArrayArbitrary, Arbitrary\UuidArbitrary
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()
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.