aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_float.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_float.rb')
-rw-r--r--test/ruby/test_float.rb12
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))