From 3bcf9fb53e4b9efabb15a3091fddfb68e5b6fbbe Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 18 Mar 2015 03:01:58 +0000 Subject: hash.c: same hash values with Float#hash * hash.c (rb_any_hash): use same hash values with Float#hash so that -0.0 and +0.0 will be identical. [ruby-core:68541] [Bug #10979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_float.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index ac2d84352b..073e382777 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -672,4 +672,12 @@ class TestFloat < Test::Unit::TestCase assert_equal(0.0, z) assert_equal(-Float::INFINITY, 1.0/z) end + + def test_hash_0 + bug10979 = '[ruby-core:68541] [Bug #10979]' + assert_equal(+0.0.hash, -0.0.hash) + assert_operator(+0.0, :eql?, -0.0) + h = {0.0 => bug10979} + assert_equal(bug10979, h[-0.0]) + end end -- cgit v1.2.3