diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | numeric.c | 1 | ||||
-rw-r--r-- | test/ruby/test_float.rb | 4 |
3 files changed, 7 insertions, 3 deletions
@@ -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. @@ -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 5d7bbb178b..e3ceaed6ad 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) |