diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-14 06:10:01 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-14 06:10:01 +0000 |
commit | 4c2e2d8bdefa8cd43adf1e28358353c1ded53049 (patch) | |
tree | 223830f7eec30a6ea0b2ba335c17547f3f7c51b7 /test/ruby/test_float.rb | |
parent | 092db4dcf0a6c9b0dc0408d4f29189754a07212e (diff) |
* numeric.c: fix flodivmod for cornercases [Bug #6044]
add ruby_float_mod
* insns.def (opt_mod): use ruby_float_mod
* internal.h: declare ruby_float_mod
* test/ruby/test_float.rb: tests for above
* test/ruby/envutil.rb: create helper assert_is_minus_zero
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_float.rb')
-rw-r--r-- | test/ruby/test_float.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 1935cfdd52..f561d00158 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -195,6 +195,18 @@ class TestFloat < Test::Unit::TestCase assert_raise(TypeError) { 2.0.send(:%, nil) } end + def test_modulo3 + bug6048 = '[ruby-core:42726]' + assert_equal(4.2, 4.2.send(:%, Float::INFINITY)) + assert_equal(4.2, 4.2 % Float::INFINITY) + assert_is_minus_zero(-0.0 % 4.2) + assert_is_minus_zero(-0.0.send :%, 4.2) + assert_raise(ZeroDivisionError) { 4.2.send(:%, 0.0) } + assert_raise(ZeroDivisionError) { 4.2 % 0.0 } + assert_raise(ZeroDivisionError) { 42.send(:%, 0) } + assert_raise(ZeroDivisionError) { 42 % 0 } + end + def test_divmod2 assert_equal([1.0, 0.0], 2.0.divmod(2)) assert_equal([1.0, 0.0], 2.0.divmod((2**32).coerce(2).first)) |