|
|
@ -46,7 +46,7 @@ module Minitest
|
|
|
|
|
|
|
|
|
|
|
|
prev_failure = database[name]
|
|
|
|
prev_failure = database[name]
|
|
|
|
|
|
|
|
|
|
|
|
unless prev_failure.nil?
|
|
|
|
if prev_failure
|
|
|
|
choices = prev_failure.unpack("Q>*")
|
|
|
|
choices = prev_failure.unpack("Q>*")
|
|
|
|
state.test_function(TestCase.for_choices(choices))
|
|
|
|
state.test_function(TestCase.for_choices(choices))
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -101,12 +101,9 @@ module Minitest
|
|
|
|
|
|
|
|
|
|
|
|
# Return True with probability `p`.
|
|
|
|
# Return True with probability `p`.
|
|
|
|
def weighted(p)
|
|
|
|
def weighted(p)
|
|
|
|
if p.zero? || p.negative?
|
|
|
|
result = if p <= 0 then forced_choice(0)
|
|
|
|
result = forced_choice(0)
|
|
|
|
elsif p >= 1 then forced_choice(1)
|
|
|
|
elsif p >= 1
|
|
|
|
else make_choice(1) { (@random.rand <= p) ? 1 : 0 }
|
|
|
|
result = forced_choice(1)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
result = make_choice(1) { (@random.rand <= p) ? 1 : 0 }
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
puts "weighted(#{p}): #{result}" if should_print?
|
|
|
|
puts "weighted(#{p}): #{result}" if should_print?
|
|
|
@ -118,7 +115,6 @@ module Minitest
|
|
|
|
# choice() had returned `n`. You almost never need this, but sometimes it
|
|
|
|
# choice() had returned `n`. You almost never need this, but sometimes it
|
|
|
|
# can be a useful hint to the shrinker.
|
|
|
|
# can be a useful hint to the shrinker.
|
|
|
|
def forced_choice(n)
|
|
|
|
def forced_choice(n)
|
|
|
|
|
|
|
|
|
|
|
|
raise RangeError.new("Invalid choice #{n}") if n.bit_length > 64 || n.negative?
|
|
|
|
raise RangeError.new("Invalid choice #{n}") if n.bit_length > 64 || n.negative?
|
|
|
|
raise Frozen unless @status.nil?
|
|
|
|
raise Frozen unless @status.nil?
|
|
|
|
|
|
|
|
|
|
|
|