ruby-changes:4375
From: ko1@a...
Date: Mon, 31 Mar 2008 19:15:02 +0900 (JST)
Subject: [ruby-changes:4375] matz - Ruby:r15866 (trunk): * numeric.c (num_quo): should convert its operand to Rational.
matz 2008-03-31 19:14:42 +0900 (Mon, 31 Mar 2008) New Revision: 15866 Modified files: trunk/ChangeLog trunk/bignum.c trunk/numeric.c trunk/rational.c trunk/test/ruby/test_bignum.rb Log: * 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] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/numeric.c?r1=15866&r2=15865&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_bignum.rb?r1=15866&r2=15865&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15866&r2=15865&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bignum.c?r1=15866&r2=15865&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/rational.c?r1=15866&r2=15865&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15865) +++ ChangeLog (revision 15866) @@ -8,6 +8,15 @@ * configure.in: check for ssize_t. [ruby-dev:34184] +Mon Mar 31 14:45:00 2008 Yukihiro Matsumoto <matz@r...> + + * 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@r...> * io.c (io_getc): set coderange while getting characters. Index: numeric.c =================================================================== --- numeric.c (revision 15865) +++ numeric.c (revision 15866) @@ -257,7 +257,7 @@ 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_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); } Index: bignum.c =================================================================== --- bignum.c (revision 15865) +++ bignum.c (revision 15866) @@ -1737,7 +1737,6 @@ /* * call-seq: * big / other => Numeric - * big.div(other) => Numeric * * Divides big by other, returning the result. */ @@ -1903,7 +1902,7 @@ 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 @@ 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); Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 15865) +++ test/ruby/test_bignum.rb (revision 15866) @@ -262,17 +262,14 @@ 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 Index: rational.c =================================================================== --- rational.c (revision 15865) +++ rational.c (revision 15866) @@ -1432,7 +1432,7 @@ 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]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/