Method: PropCheck::Generators.real_float
- Defined in:
- lib/prop_check/generators.rb
.real_float ⇒ Object
Generates floating-point numbers These start small (around 0) and become more extreme (large positive and large negative numbers)
Will only generate ‘reals’, that is: no infinity, no NaN, no numbers testing the limits of floating-point arithmetic.
Shrinks towards zero. The shrinking strategy also moves towards ‘simpler’ floats (like 1.0) from ‘complicated’ floats (like 3.76543).
>> Generators.real_float().sample(10, size: 10, rng: Random.new(42))
=> [-2.2, -0.2727272727272727, 4.0, 1.25, -3.7272727272727275, -8.833333333333334, -8.090909090909092, 1.1428571428571428, 0.0, 8.0]
144 145 146 147 148 |
# File 'lib/prop_check/generators.rb', line 144 def real_float tuple(integer, integer, integer).map do |a, b, c| fraction(a, b, c) end end |