summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-03 02:05:17 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-03 02:05:17 +0000
commit05ba99388d1133a99153044be67d7ae3b3dc4de5 (patch)
tree65dbfbf917e2bfd12a5caf31d23b59aee67302bb
parente25eace6a6300470861ea6c40d4e2172e06bbb8d (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--bignum.c2
-rw-r--r--numeric.c2
-rw-r--r--test/ruby/test_bignum.rb4
-rw-r--r--test/ruby/test_integer.rb15
-rw-r--r--version.h8
5 files changed, 25 insertions, 6 deletions
diff --git a/bignum.c b/bignum.c
index 4b50737bb6..ef2b716cff 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6159,7 +6159,7 @@ rb_big_fdiv_double(VALUE x, VALUE y)
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;
}
diff --git a/numeric.c b/numeric.c
index f36f3b1163..631e199dcc 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3629,7 +3629,7 @@ fix_fdiv_double(VALUE x, VALUE y)
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")));
}
}
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 15811d5d43..7c046cbbfd 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -693,6 +693,10 @@ class TestBignum < Test::Unit::TestCase
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
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 0a6b2f4539..b1952b643a 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -464,4 +464,19 @@ class TestInteger < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index 6f9f64a3af..78da54bb0b 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#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"