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:
nobu 2012-10-09 09:01:40 +00:00
parent 7f8e558464
commit e3efce6df1
5 changed files with 41 additions and 22 deletions

View file

@ -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