зеркало из https://github.com/github/ruby.git
* 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:
Родитель
3dc6edf793
Коммит
7e4015e16d
|
@ -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,
|
||||
|
|
3
array.c
3
array.c
|
@ -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) {
|
||||
|
|
|
@ -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))
|
||||
|
|
Загрузка…
Ссылка в новой задаче