IntArbitrary
Rasuvaeff\PropertyTesting\Arbitrary\IntArbitrary
Class — Package: property-testing-core — Source — Version: v1.0.0-1-g88fdee2
Implements: Enumerable, ArbitraryInterface
Generates integers within an inclusive range and shrinks them toward zero (clamped into the range, so the target of a zero-free range is its nearest bound).
Generation is biased: roughly one draw in Arbitrary\BIAS_DENOMINATOR returns an in-range boundary value (0, ±1, min, max) instead of a uniform one, because bugs cluster at edges.
The shrink tree halves the distance to the target: the target itself first, then candidates progressively closer to the failing value, each with its own subtree toward the same target — a binary search for the minimal failing integer.
Constructor
__construct(
int $min = PHP_INT_MIN,
int $max = PHP_INT_MAX,
)| Parameter | Type | Default | Description |
|---|---|---|---|
$min | int | PHP_INT_MIN | |
$max | int | PHP_INT_MAX |
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.
domainSize()
domainSize(): ?intSaturates: a range wider than PHP_INT_MAX values (the full int range above all) reports PHP_INT_MAX, which no budget accepts.
enumerate()
enumerate(): iterableAscending from the minimum.