MappedArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\MappedArbitrary
Class — Package: property-testing-core — Source — Version: v0.1.0-12-g86ead85
Implements: ArbitraryInterface
Type parameters:
TInner of mixed = mixedTOutput 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
__construct(
\ArbitraryInterface<\Arbitrary\TInner> $inner,
callable $map,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$inner | \ArbitraryInterface<\Arbitrary\TInner> | required | |
$map | callable | 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.