1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_shuffle_bang): check number of argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-08-26 00:49:54 +00:00
parent 3dc6edf793
commit 7e4015e16d
3 changed files with 8 additions and 0 deletions

View file

@ -1,3 +1,7 @@
Thu Aug 26 09:49:50 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (rb_ary_shuffle_bang): check number of argument.
Tue Aug 26 09:11:40 2010 Kenta Murata <mrkn@mrkn.jp>
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal,

View file

@ -3754,6 +3754,9 @@ rb_ary_shuffle_bang(int argc, VALUE *argv, VALUE ary)
if (OPTHASH_GIVEN_P(opts)) {
randgen = rb_hash_lookup2(opts, sym_random, randgen);
}
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
rb_ary_modify(ary);
ptr = RARRAY_PTR(ary);
while (i) {

View file

@ -1893,6 +1893,7 @@ class TestArray < Test::Unit::TestCase
end
gen = Random.new(0)
assert_raise(ArgumentError) {[1, 2, 3].shuffle(1, random: gen)}
srand(0)
100.times do
assert_equal([0, 1, 2].shuffle, [0, 1, 2].shuffle(random: gen))