summaryrefslogtreecommitdiff
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb10
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)