mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 22:45:03 +02:00
array.c: use rb_random_ulong_limited
* array.c (rb_ary_sample): use rb_random_ulong_limited, since precision of long may be larger than double. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7f8e558464
commit
e3efce6df1
5 changed files with 41 additions and 22 deletions
|
@ -170,8 +170,9 @@ class TestRand < Test::Unit::TestCase
|
|||
|
||||
def test_shuffle
|
||||
srand(0)
|
||||
assert_equal([1,4,2,5,3], [1,2,3,4,5].shuffle)
|
||||
assert_equal([1,4,2,5,3], [1,2,3,4,5].shuffle(random: Random.new(0)))
|
||||
result = [*1..5].shuffle
|
||||
assert_equal([*1..5], result.sort)
|
||||
assert_equal(result, [*1..5].shuffle(random: Random.new(0)))
|
||||
end
|
||||
|
||||
def test_big_seed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue