numeric.c: 0 % Float::NAN returns Float::NAN

* numeric.c (flodivmod): all results are NaN if divisor is NaN.
  [fix GH-692]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-08-01 07:35:48 +00:00
parent 528ef3ca93
commit 52b59fc9d9
3 changed files with 18 additions and 1 deletions

View file

@ -271,6 +271,12 @@ class TestFloat < Test::Unit::TestCase
assert_raise(ZeroDivisionError, bug6048) { 42 % 0 }
end
def test_modulo4
assert_predicate((0.0).modulo(Float::NAN), :nan?)
assert_predicate((1.0).modulo(Float::NAN), :nan?)
assert_predicate(Float::INFINITY.modulo(1), :nan?)
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))