Class: NegativeInteger
Constant Summary collapse
- @@max_bound =
-1
- @@min_bound =
-(2**30)
Class Method Summary collapse
-
.arbitrary ⇒ Object
this method is needed to use Arbitrary.
-
.random_range(gen, lo = @@min_bound, hi = @@max_bound) ⇒ Object
this method is needed to include HsRandom.
Methods inherited from Integer
Methods included from RushCheck::HsRandom
#random, #random_array, #random_std
Methods included from RushCheck::Arbitrary
Methods included from RushCheck::Coarbitrary
Class Method Details
.arbitrary ⇒ Object
this method is needed to use Arbitrary.
96 97 98 99 100 101 |
# File 'lib/rushcheck/integer.rb', line 96 def self.arbitrary RushCheck::Gen.sized do |n| n = (-1) - n if n >= 0 RushCheck::Gen.choose(n, -1) end end |
.random_range(gen, lo = @@min_bound, hi = @@max_bound) ⇒ Object
this method is needed to include HsRandom.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rushcheck/integer.rb', line 83 def self.random_range(gen, lo=@@min_bound, hi=@@max_bound) hi, lo = lo, hi if hi < lo raise RuntimeError, "NegativeInteger requires negative upper bound." if hi >= 0 v, g = gen.gen_next d = hi - lo + 1 if d == 1 then [lo, g] else [(v % d) + lo, g] end end |