зеркало из https://github.com/github/ruby.git
Numeral#step should raise TypeError if a non-numeric parameter is given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3065dd71e8
Коммит
4993cf9e24
|
@ -1,3 +1,8 @@
|
|||
Tue Sep 3 07:31:29 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* numeric.c (NUM_STEP_SCAN_ARGS): Numeral#step should raise
|
||||
TypeError if a non-numeric parameter is given.
|
||||
|
||||
Tue Sep 3 07:28:49 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* internal.h (bit_length): Add casts to fix complation error with
|
||||
|
|
18
numeric.c
18
numeric.c
|
@ -1858,9 +1858,23 @@ ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
|
|||
rb_raise(rb_eArgError, "step can't be 0"); \
|
||||
} \
|
||||
} \
|
||||
if (NIL_P(step)) step = INT2FIX(1); \
|
||||
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); \
|
||||
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"); \
|
||||
} \
|
||||
} \
|
||||
if (TYPE(to) == T_FLOAT) { \
|
||||
double f = RFLOAT_VALUE(to); \
|
||||
inf = isinf(f) && (signbit(f) ? desc : !desc); \
|
||||
|
|
Загрузка…
Ссылка в новой задаче