mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Split test of Hash.[] and add assertion for default value/proc
For a73f13c907
.
This commit is contained in:
parent
771f6dd75d
commit
7a2383b5c1
1 changed files with 11 additions and 1 deletions
|
@ -142,7 +142,7 @@ class TestHash < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_s_AREF
|
||||
def test_s_AREF_from_hash
|
||||
h = @cls["a" => 100, "b" => 200]
|
||||
assert_equal(100, h['a'])
|
||||
assert_equal(200, h['b'])
|
||||
|
@ -153,11 +153,21 @@ class TestHash < Test::Unit::TestCase
|
|||
assert_equal(200, h['b'])
|
||||
assert_nil(h['c'])
|
||||
|
||||
h = @cls[Hash.new(42)]
|
||||
assert_nil(h['a'])
|
||||
|
||||
h = @cls[Hash.new {42}]
|
||||
assert_nil(h['a'])
|
||||
end
|
||||
|
||||
def test_s_AREF_from_list
|
||||
h = @cls["a", 100, "b", 200]
|
||||
assert_equal(100, h['a'])
|
||||
assert_equal(200, h['b'])
|
||||
assert_nil(h['c'])
|
||||
end
|
||||
|
||||
def test_s_AREF_from_pairs
|
||||
h = @cls[[["a", 100], ["b", 200]]]
|
||||
assert_equal(100, h['a'])
|
||||
assert_equal(200, h['b'])
|
||||
|
|
Loading…
Reference in a new issue