1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* hash.c (rb_hash): always return a fixnum value because a return

value of rb_hash may be used as a hash value itself and bignums have
  no unique VALUE.

* test/ruby/test_hash.rb: add a test for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2009-02-14 18:53:40 +00:00
parent 766df600db
commit a48f90b05b
3 changed files with 33 additions and 5 deletions

View file

@ -849,4 +849,15 @@ class TestHash < Test::Unit::TestCase
def test_hash_hash
assert_equal({0=>2,11=>1}.hash, {11=>1,0=>2}.hash)
end
def test_hash_bignum_hash
x = 2<<(32-3)-1
assert_equal({x=>1}.hash, {x=>1}.hash)
x = 2<<(64-3)-1
assert_equal({x=>1}.hash, {x=>1}.hash)
o = Object.new
def o.hash; 2<<100; end
assert_equal({x=>1}.hash, {x=>1}.hash)
end
end