-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
This case is from CRuby's test_rand.rb, test_random_ulong_limited_no_rand:
def test_random_ulong_limited_no_rand
c = Class.new do
undef rand
def bytes(n)
"\0"*n
end
end
gen = c.new.extend(Random::Formatter)
assert_equal(1, [1, 2].sample(random: gen))
end
The problem here is that the random: passed in still gets used by calling rand which produces a random number, rather than using the bytes method to generate a random number {which should be the same always due to the constant return value).
This broke along with other changes to Random to support the SecureRandom gem and user-defined random byte generation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels