diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-20 15:06:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-20 15:06:56 +0000 |
commit | abe75149d14d3286d3051c9e961ab6473a243a19 (patch) | |
tree | f33ad9fcd4569f51d7f0b85fefb751597211438d /test/ruby/test_hash.rb | |
parent | e76eebd79be9fa3cb59d0ea6e4ce8214cc6e56ad (diff) | |
download | ruby-abe75149d14d3286d3051c9e961ab6473a243a19.tar.gz |
Enumerable#to_h with block and so on
[Feature #15143]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 11735c5620..6aaeddc9d4 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -847,6 +847,16 @@ class TestHash < Test::Unit::TestCase assert_equal("nope42", h[42]) end + def test_to_h_block + h = @h.to_h {|k, v| [k.to_s, v.to_s]} + assert_equal({ + "1"=>"one", "2"=>"two", "3"=>"three", to_s=>"self", + "true"=>"true", ""=>"nil", "nil"=>"" + }, + h) + assert_instance_of(Hash, h) + end + def test_nil_to_h h = nil.to_h assert_equal({}, h) |