ruby-changes:50053
From: nagachika <ko1@a...>
Date: Sat, 3 Feb 2018 11:05:23 +0900 (JST)
Subject: [ruby-changes:50053] nagachika:r62171 (ruby_2_4): merge revision(s) 59986: [Backport #13928]
nagachika 2018-02-03 11:05:17 +0900 (Sat, 03 Feb 2018) New Revision: 62171 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62171 Log: merge revision(s) 59986: [Backport #13928] numeric.c: use NUM2DBL * numeric.c (fix_fdiv_double), bignum.c (rb_big_fdiv_double): use NUM2DBL on unknown object. RFLOAT_VALUE is only appliicable to T_FLOAT object. [ruby-core:82924] [Bug #13928] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/bignum.c branches/ruby_2_4/numeric.c branches/ruby_2_4/test/ruby/test_bignum.rb branches/ruby_2_4/test/ruby/test_integer.rb branches/ruby_2_4/version.h Index: ruby_2_4/bignum.c =================================================================== --- ruby_2_4/bignum.c (revision 62170) +++ ruby_2_4/bignum.c (revision 62171) @@ -6159,7 +6159,7 @@ rb_big_fdiv_double(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/bignum.c#L6159 return big_fdiv_float(x, y); } else { - return RFLOAT_VALUE(rb_num_coerce_bin(x, y, rb_intern("fdiv"))); + return NUM2DBL(rb_num_coerce_bin(x, y, rb_intern("fdiv"))); } return dx / dy; } Index: ruby_2_4/test/ruby/test_integer.rb =================================================================== --- ruby_2_4/test/ruby/test_integer.rb (revision 62170) +++ ruby_2_4/test/ruby/test_integer.rb (revision 62171) @@ -464,4 +464,19 @@ class TestInteger < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_integer.rb#L464 end assert_equal([0, 1], 10.digits(o)) end + + def test_fdiv + assert_equal(1.0, 1.fdiv(1)) + assert_equal(0.5, 1.fdiv(2)) + end + + def test_obj_fdiv + o = Object.new + def o.coerce(x); [x, 0.5]; end + assert_equal(2.0, 1.fdiv(o)) + o = Object.new + def o.coerce(x); [self, x]; end + def o.fdiv(x); 1; end + assert_equal(1.0, 1.fdiv(o)) + end end Index: ruby_2_4/test/ruby/test_bignum.rb =================================================================== --- ruby_2_4/test/ruby/test_bignum.rb (revision 62170) +++ ruby_2_4/test/ruby/test_bignum.rb (revision 62171) @@ -693,6 +693,10 @@ class TestBignum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_bignum.rb#L693 o = Object.new def o.coerce(x); [x, 2**100]; end assert_equal((2**200).to_f, (2**300).fdiv(o)) + o = Object.new + def o.coerce(x); [self, x]; end + def o.fdiv(x); 1; end + assert_equal(1.0, (2**300).fdiv(o)) end def test_singleton_method Index: ruby_2_4/numeric.c =================================================================== --- ruby_2_4/numeric.c (revision 62170) +++ ruby_2_4/numeric.c (revision 62171) @@ -3629,7 +3629,7 @@ fix_fdiv_double(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/numeric.c#L3629 return (double)FIX2LONG(x) / RFLOAT_VALUE(y); } else { - return RFLOAT_VALUE(rb_num_coerce_bin(x, y, rb_intern("fdiv"))); + return NUM2DBL(rb_num_coerce_bin(x, y, rb_intern("fdiv"))); } } Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 62170) +++ ruby_2_4/version.h (revision 62171) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" -#define RUBY_RELEASE_DATE "2018-01-15" -#define RUBY_PATCHLEVEL 228 +#define RUBY_RELEASE_DATE "2018-02-03" +#define RUBY_PATCHLEVEL 229 #define RUBY_RELEASE_YEAR 2018 -#define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_MONTH 2 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 62170) +++ ruby_2_4 (revision 62171) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59986 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/