From 8554e163557a4f32f6e9427146d594df31ac024a Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 25 Aug 2010 22:30:03 +0000 Subject: * array.c (rb_ary_{shuffle_bang,sample}): use Random class object. * random.c (try_get_rnd): use default_rand for Random as same as singleton methods. * random.c (rb_random_real): check the range of result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_array.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index f95d8870a1..4a8b700c77 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1899,6 +1899,19 @@ class TestArray < Test::Unit::TestCase end end + def test_shuffle_random + cc = nil + gen = proc do + 10000000 + end + class << gen + alias rand call + end + assert_raise(RangeError) { + [*0..2].shuffle(random: gen) + } + end + def test_sample 100.times do assert([0, 1, 2].include?([2, 1, 0].sample)) -- cgit v1.2.3