Skip to content

FloatArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\FloatArbitrary

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

Implements: ArbitraryInterface

Generates floats in the half-open range [min, max).

Generation is biased: roughly one draw in Arbitrary\BIAS_DENOMINATOR returns an in-range boundary value (0.0 or min) instead of a uniform one, because bugs cluster at edges. The exclusive upper bound is never emitted.

Shrinking floats reliably is hard (no natural "smallest" value), so the shrink tree has a single candidate: zero, clamped into the configured range. For fine-grained shrinking on a numeric input, generate an integer and Gen::map() it to a float — with integrated shrinking the mapped value shrinks through the integer's tree.

Constructor

php
__construct(
    float $min = 0.0,
    float $max = 1.0,
)
ParameterTypeDefaultDescription
$minfloat0.0
$maxfloat1.0

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.