diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-08 06:55:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-08 06:55:24 +0000 |
commit | ab6efa5be2f5a2fb1b5a05a90f398b27ea52617a (patch) | |
tree | 621c25b0d22646d05c80e79886314a79061b86b4 /test | |
parent | 06f624b8915fbddbb13c010ee1a61f266708285b (diff) | |
download | ruby-ab6efa5be2f5a2fb1b5a05a90f398b27ea52617a.tar.gz |
object.c: hash value from objid with salt
* hash.c (rb_objid_hash): return hash value from object ID with a
salt, extract from rb_any_hash().
* object.c (rb_obj_hash): return same value as rb_any_hash().
fix r44125. [ruby-core:59638] [Bug #9381]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_hash.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 70c04424db..3861fde0a4 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1215,6 +1215,27 @@ class TestHash < Test::Unit::TestCase assert_no_memory_leak([], prepare, code, bug9187) end + def test_wrapper_of_special_const + bug9381 = '[ruby-core:59638] [Bug #9381]' + + wrapper = Class.new do + def initialize(obj) + @obj = obj + end + + def hash + @obj.hash + end + + def eql?(other) + @obj.eql?(other) + end + end + + hash = {5 => bug9381} + assert_equal(bug9381, hash[wrapper.new(5)]) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) |