SubsetArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\SubsetArbitrary
Class — Package: property-testing-core — Source — Version: v0.1.0-12-g86ead85
Implements: ArbitraryInterface
Type parameters:
TValue of mixed = mixed
Generates subsets of a fixed ordered set: every result is a list of distinct elements of the source list, in the source list's order. Distribution is uniform over the allowed sizes first (each size in [minSize, maxSize] is equally likely), then uniform over the combinations of that size — small and large subsets appear equally often, which a uniform-over-all-subsets draw would not give.
Shrinking reduces the subset's size first (empty set, halved prefixes, single-element removals), then moves each kept element toward earlier positions of the source list — the minimal falsifying subset therefore gravitates to a short prefix of the source. Every candidate strictly decreases the pair (size, sum of source positions), so the descent is finite by construction; no filtering, no discards.
Constructor
__construct(
list<\Arbitrary\TValue> $values,
int $minSize = 0,
?int $maxSize = NULL,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$values | list<\Arbitrary\TValue> | required | The source set, as an ordered list. Duplicates (strict comparison) are rejected — a set has no duplicate members. |
$minSize | int | 0 | |
$maxSize | ?int | NULL | Null means the full source size. |
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.