Sha256: 441dca30d28aba2691779e88c8da74c19e45f42f5bb937e6ffe89dd3d677668d
Contents?: true
Size: 495 Bytes
Versions: 6
Compression:
Stored size: 495 Bytes
Contents
require 'queencheck/arbitrary' class Float extend QueenCheck::Arbitrary @@bound = 25 set_arbitrary do |seed| if seed == 0 0.0 else if seed > 0.9 && rand(3) > 0 return rand(2).zero? ? 0.0/0.0 : rand(2).zero? ? 1.0/0 : -1.0/0 end base = ((@@bound * seed).ceil).to_f max = 10.0 ** base num = rand(max) nod = num.to_s.length num.to_f / (10 ** ((rand(nod / 2) + nod / 2) / 2)) * (rand(2).zero? ? 1.0 : -1.0) end end end
Version data entries
6 entries across 6 versions & 1 rubygems