Skip to content

MappedArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\MappedArbitrary

ClassPackage: property-testing-coreSourceVersion: v0.1.0-12-g86ead85

Implements: ArbitraryInterface

Type parameters:

  • TInner of mixed = mixed
  • TOutput of mixed = mixed

Transforms each value produced by a delegate arbitrary through a pure function.

The whole shrink tree is mapped: shrinking happens in the inner (source) domain and the function is re-applied to every candidate, so the shrunk counterexample is reported in the transformed domain. The function must be pure — it runs once per generated value and once per visited candidate.

Constructor

php
__construct(
    \ArbitraryInterface<\Arbitrary\TInner> $inner,
    callable $map,
)
ParameterTypeDefaultDescription
$inner\ArbitraryInterface<\Arbitrary\TInner>required
$mapcallablerequired

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.