FrequencyArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\FrequencyArbitrary
Class — Package: property-testing-core — Source — Version: v0.1.0-12-g86ead85
Implements: ArbitraryInterface
Type parameters:
TValue of mixed = mixed
Weighted choice among several arbitraries: each [weight, arbitrary] pair is picked with probability proportional to its (positive integer) weight, then the chosen arbitrary produces the value.
The chosen branch's shrink tree is returned as-is, so shrinking stays within the branch that actually generated the value.
Constructor
__construct(
iterable $pairs,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$pairs | iterable | required | Each item must be [int $weight, ArbitraryInterface $arbitrary] with $weight >= 1. |
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.