diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-25 09:31:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-25 09:31:46 +0000 |
commit | fd1022c065509846dd234914e3c9b725d20e928a (patch) | |
tree | b9db58a6b8d6a0567a4daff22e538d77dfbc0e88 /test | |
parent | ae6a9009dcb5e475ef51a3448a613e7f4428855d (diff) | |
download | ruby-fd1022c065509846dd234914e3c9b725d20e928a.tar.gz |
* random.c (rb_random_real): check the range of result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_array.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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)) |