diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-05 05:38:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-05 05:38:15 +0000 |
commit | 19be85f7d1ca47266ab6e0435fa0f3a41aa59fad (patch) | |
tree | d4abe876d06e38214253bd94d946fe7f39ae5e16 | |
parent | 1402333810cae580ffe90e2cc635a47ed4be8f68 (diff) | |
download | ruby-19be85f7d1ca47266ab6e0435fa0f3a41aa59fad.tar.gz |
test_hash.rb: import tests from rubyspec
* test/ruby/test_hash.rb: import tests for recursive hash values
from rubyspec/core/{array,hash}/hash_spec.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_hash.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 98555824bc..6aaba469db 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1111,6 +1111,32 @@ class TestHash < Test::Unit::TestCase assert_same(obj, h[[[a]]]) end + def test_recursive_hash_value_array_hash + h = @cls[] + rec = [h] + h[:x] = rec + + obj = Object.new + h2 = {rec => obj} + [h, {x: rec}].each do |k| + k = [k] + assert_same(obj, h2[k], ->{k.inspect}) + end + end + + def test_recursive_hash_value_hash_array + h = @cls[] + rec = [h] + h[:x] = rec + + obj = Object.new + h2 = {h => obj} + [rec, [h]].each do |k| + k = {x: k} + assert_same(obj, h2[k], ->{k.inspect}) + end + end + def test_exception_in_rehash bug9187 = '[ruby-core:58728] [Bug #9187]' |