зеркало из https://github.com/github/ruby.git
* numeric.c (num_quo): should convert its operand to Rational.
* rational.c (string_to_r_strict): should raise TypeError. * bignum.c (Init_Bignum): should not redefine Bignum#div. Numeric#div will do. [ruby-dev:34066] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b2acbb2c67
Коммит
88a4961cb2
|
@ -8,6 +8,15 @@ Mon Mar 31 18:42:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
* configure.in: check for ssize_t. [ruby-dev:34184]
|
||||
|
||||
Mon Mar 31 14:45:00 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* numeric.c (num_quo): should convert its operand to Rational.
|
||||
|
||||
* rational.c (string_to_r_strict): should raise TypeError.
|
||||
|
||||
* bignum.c (Init_Bignum): should not redefine Bignum#div.
|
||||
Numeric#div will do. [ruby-dev:34066]
|
||||
|
||||
Mon Mar 31 04:05:15 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* io.c (io_getc): set coderange while getting characters.
|
||||
|
|
4
bignum.c
4
bignum.c
|
@ -1737,7 +1737,6 @@ bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
|
|||
/*
|
||||
* call-seq:
|
||||
* big / other => Numeric
|
||||
* big.div(other) => Numeric
|
||||
*
|
||||
* Divides big by other, returning the result.
|
||||
*/
|
||||
|
@ -1903,7 +1902,7 @@ static VALUE big_shift(VALUE x, int n)
|
|||
static VALUE
|
||||
rb_big_quo(VALUE x, VALUE y)
|
||||
{
|
||||
return rb_funcall(rb_rational_raw1(x), '/', 1, y);
|
||||
return rb_funcall(rb_rational_raw1(x), '/', 1, rb_Rational1(y));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -2598,7 +2597,6 @@ Init_Bignum(void)
|
|||
rb_define_method(rb_cBignum, "*", rb_big_mul, 1);
|
||||
rb_define_method(rb_cBignum, "/", rb_big_div, 1);
|
||||
rb_define_method(rb_cBignum, "%", rb_big_modulo, 1);
|
||||
rb_define_method(rb_cBignum, "div", rb_big_div, 1);
|
||||
rb_define_method(rb_cBignum, "divmod", rb_big_divmod, 1);
|
||||
rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1);
|
||||
rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);
|
||||
|
|
|
@ -257,7 +257,7 @@ num_uminus(VALUE num)
|
|||
static VALUE
|
||||
num_quo(VALUE x, VALUE y)
|
||||
{
|
||||
return rb_funcall(x, '/', 1, y);
|
||||
return rb_funcall(x, '/', 1, rb_Rational1(y));
|
||||
}
|
||||
|
||||
|
||||
|
@ -275,7 +275,7 @@ static VALUE num_floor(VALUE num);
|
|||
static VALUE
|
||||
num_div(VALUE x, VALUE y)
|
||||
{
|
||||
return num_floor(rb_funcall(x, '/', 1, y));
|
||||
return rb_funcall(rb_funcall(x, '/', 1, y), rb_intern("floor"), 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1432,7 +1432,7 @@ string_to_r_strict(VALUE self)
|
|||
VALUE a = string_to_r_internal(self);
|
||||
if (NIL_P(RARRAY_PTR(a)[0]) || RSTRING_LEN(RARRAY_PTR(a)[1]) > 0) {
|
||||
VALUE s = f_inspect(self);
|
||||
rb_raise(rb_eArgError, "invalid value for Rational: %s",
|
||||
rb_raise(rb_eTypeError, "invalid value for Rational: %s",
|
||||
StringValuePtr(s));
|
||||
}
|
||||
return RARRAY_PTR(a)[0];
|
||||
|
|
|
@ -262,17 +262,14 @@ class TestBignum < Test::Unit::TestCase
|
|||
assert_equal(T32.to_f, T32.quo(1.0))
|
||||
assert_equal(T32.to_f, T32.quo(T_ONE))
|
||||
|
||||
### rational changes the behavior of Bignum#quo
|
||||
#assert_raise(TypeError) { T32.quo("foo") }
|
||||
assert_raise(TypeError, NoMethodError) { T32.quo("foo") }
|
||||
assert_raise(TypeError) { T32.quo("foo") }
|
||||
|
||||
assert_equal(1024**1024, (1024**1024).quo(1))
|
||||
assert_equal(1024**1024, (1024**1024).quo(1.0))
|
||||
assert_equal(1024**1024*2, (1024**1024*2).quo(1))
|
||||
inf = 1 / 0.0; nan = inf / inf
|
||||
|
||||
### rational changes the behavior of Bignum#quo
|
||||
#assert_raise(FloatDomainError) { (1024**1024*2).quo(nan) }
|
||||
assert_raise(FloatDomainError) { (1024**1024*2).quo(nan) }
|
||||
end
|
||||
|
||||
def test_pow
|
||||
|
|
Загрузка…
Ссылка в новой задаче