зеркало из https://github.com/github/ruby.git
Suppress keyword argument warning from #step
* numeric.c (num_step): pass the extracted argument from keyword argument, not the last argument itself which should have been warned already.
This commit is contained in:
Родитель
f39314a98a
Коммит
59648af296
|
@ -2768,7 +2768,7 @@ num_step(int argc, VALUE *argv, VALUE from)
|
|||
num_step_size, from, to, step, FALSE);
|
||||
}
|
||||
|
||||
RETURN_SIZED_ENUMERATOR(from, argc, argv, num_step_size);
|
||||
return SIZED_ENUMERATOR(from, 2, ((VALUE [2]){to, step}), num_step_size);
|
||||
}
|
||||
|
||||
desc = num_step_scan_args(argc, argv, &to, &step, TRUE, FALSE);
|
||||
|
|
|
@ -292,6 +292,14 @@ class TestNumeric < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11) {} }
|
||||
assert_raise(ArgumentError, bug9811) { 1.step(10, 1, by: 11).size }
|
||||
|
||||
|
||||
e = assert_warn(/The last argument is used as the keyword parameter/) {
|
||||
1.step(10, {by: "1"})
|
||||
}
|
||||
assert_warn('') {
|
||||
assert_raise(ArgumentError) {e.size}
|
||||
}
|
||||
|
||||
assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size)
|
||||
assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче