зеркало из https://github.com/github/ruby.git
numeric.c: no extra checks
* numeric.c (NUM_STEP_SCAN_ARGS): remove extra class checks, which cause the incompatibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
622a2af0ba
Коммит
ba6c734847
10
numeric.c
10
numeric.c
|
@ -1864,20 +1864,10 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
|
|||
if (NIL_P(step)) { \
|
||||
step = INT2FIX(1); \
|
||||
} \
|
||||
else { \
|
||||
if (!rb_obj_is_kind_of(step, rb_cNumeric)) { \
|
||||
rb_raise(rb_eTypeError, "step must be numeric"); \
|
||||
} \
|
||||
} \
|
||||
desc = negative_int_p(step); \
|
||||
if (NIL_P(to)) { \
|
||||
to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY); \
|
||||
} \
|
||||
else { \
|
||||
if (!rb_obj_is_kind_of(to, rb_cNumeric)) { \
|
||||
rb_raise(rb_eTypeError, "limit must be numeric"); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define NUM_STEP_GET_INF(to, desc, inf) do { \
|
||||
|
|
|
@ -558,7 +558,7 @@ class TestFloat < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_num2dbl
|
||||
assert_raise(TypeError) do
|
||||
assert_raise(ArgumentError) do
|
||||
1.0.step(2.0, "0.5") {}
|
||||
end
|
||||
assert_raise(TypeError) do
|
||||
|
|
|
@ -227,8 +227,8 @@ class TestNumeric < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { 1.step(10, 1, 0).size }
|
||||
assert_raise(ArgumentError) { 1.step(10, 0) { } }
|
||||
assert_raise(ArgumentError) { 1.step(10, 0).size }
|
||||
assert_raise(TypeError) { 1.step(10, "1") { } }
|
||||
assert_raise(TypeError) { 1.step(10, "1").size }
|
||||
assert_raise(ArgumentError) { 1.step(10, "1") { } }
|
||||
assert_raise(ArgumentError) { 1.step(10, "1").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) }
|
||||
|
|
Загрузка…
Ссылка в новой задаче