mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
1402333810
commit
19be85f7d1
1 changed files with 26 additions and 0 deletions
|
@ -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]'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue