зеркало из https://github.com/github/ruby.git
Retain behavior of Numeric#step when nil is given as second argument.
* numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep Numeral#step backward compatible in that it raises TypeError when nil is given as second argument. * test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert. * test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test cases for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0c3d124571
Коммит
c68596aef1
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Tue Sep 3 07:49:25 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep
|
||||
Numeral#step backward compatible in that it raises TypeError
|
||||
when nil is given as second argument.
|
||||
|
||||
* test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert.
|
||||
|
||||
* test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test
|
||||
cases for the above change.
|
||||
|
||||
Tue Sep 3 07:39:58 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (bytes_2comp): Define it only for little endian
|
||||
|
|
|
@ -1854,6 +1854,9 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
|
|||
} \
|
||||
else { \
|
||||
/* compatibility */ \
|
||||
if (argc > 1 && NIL_P(step)) { \
|
||||
rb_raise(rb_eTypeError, "step must be numeric"); \
|
||||
} \
|
||||
if (rb_equal(step, INT2FIX(0))) { \
|
||||
rb_raise(rb_eArgError, "step can't be 0"); \
|
||||
} \
|
||||
|
|
|
@ -561,6 +561,9 @@ class TestFloat < Test::Unit::TestCase
|
|||
assert_raise(TypeError) do
|
||||
1.0.step(2.0, "0.5") {}
|
||||
end
|
||||
assert_raise(TypeError) do
|
||||
1.0.step(2.0, nil) {}
|
||||
end
|
||||
end
|
||||
|
||||
def test_sleep_with_Float
|
||||
|
|
|
@ -229,8 +229,8 @@ class TestNumeric < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { 1.step(10, 0).size }
|
||||
assert_raise(TypeError) { 1.step(10, "1") { } }
|
||||
assert_raise(TypeError) { 1.step(10, "1").size }
|
||||
assert_nothing_raised { 1.step(10, nil) { } }
|
||||
assert_nothing_raised { 1.step(10, nil).size }
|
||||
assert_raise(TypeError) { 1.step(10, nil) { } }
|
||||
assert_raise(TypeError) { 1.step(10, nil).size }
|
||||
assert_nothing_raised { 1.step(by: 0, to: nil) }
|
||||
assert_nothing_raised { 1.step(by: 0, to: nil).size }
|
||||
assert_nothing_raised { 1.step(by: 0) }
|
||||
|
|
Загрузка…
Ссылка в новой задаче