summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-30 05:13:10 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-30 05:13:10 +0000
commit9c0d94449bd9f6304179ecdb9294b30cb6e51319 (patch)
tree3aa680e2ebf27da2fd68d20a7c00cd43c71393b8 /test
parent0b81093a7e7a4c4283b1918672f7fed83e545a1c (diff)
merge revision(s) 35013:
* 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/branches/ruby_1_9_3@35176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/envutil.rb4
-rw-r--r--test/ruby/test_float.rb12
2 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index ef5f65c747..73f0101ac1 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -184,6 +184,10 @@ module Test
assert(msg === stderr, "warning message #{stderr.inspect} is expected to match #{msg.inspect}")
end
+
+ def assert_is_minus_zero(f)
+ assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0")
+ end
end
end
end
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index c244447bd7..440fd39bbe 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))