summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-27 16:01:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-27 16:01:54 +0000
commita07efb300115c35155b397076ce5b95a52a4db8d (patch)
tree2276bd860fd361dfb0ef2d22d12cf391040b484a
parent0df3df6925b8c89ae8b000caabe9889ebc3e7804 (diff)
downloadruby-a07efb300115c35155b397076ce5b95a52a4db8d.tar.gz
ruby-a07efb300115c35155b397076ce5b95a52a4db8d.tar.xz
ruby-a07efb300115c35155b397076ce5b95a52a4db8d.zip
* numeric.c (flodivmod): floating point division should raise
ZeroDivisionError as integer division. [incompatible] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--numeric.c1
-rw-r--r--test/ruby/test_float.rb4
3 files changed, 7 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index cbdf67c8c..08739594b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Nov 28 00:12:00 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (flodivmod): floating point division should raise
+ ZeroDivisionError as integer division. [incompatible]
+
Thu Nov 27 23:54:37 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (gc_mark): still needs to check stack depth during GC.
diff --git a/numeric.c b/numeric.c
index c2f5e60c1..29497b064 100644
--- a/numeric.c
+++ b/numeric.c
@@ -678,6 +678,7 @@ flodivmod(double x, double y, double *divp, double *modp)
{
double div, mod;
+ if (y == 0.0) rb_num_zerodiv();
#ifdef HAVE_FMOD
mod = fmod(x, y);
#else
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index 5d7bbb178..e3ceaed6a 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -172,9 +172,7 @@ class TestFloat < Test::Unit::TestCase
assert_raise(TypeError) { 2.0.divmod(nil) }
inf = 1.0 / 0.0
- a, b = inf.divmod(0)
- assert(a.infinite?)
- assert(b.nan?)
+ assert_raise(ZeroDivisionError) {inf.divmod(0)}
a, b = (2.0**32).divmod(1.0)
assert_equal(2**32, a)