Skip to content

IntArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\IntArbitrary

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

Implements: 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

php
__construct(
    int $min = PHP_INT_MIN,
    int $max = PHP_INT_MAX,
)
ParameterTypeDefaultDescription
$minintPHP_INT_MIN
$maxintPHP_INT_MAX

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.