From fbe967ec02cb65a7efa3fb8f3d747cf6f620dde1 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 10 Nov 2015 07:57:17 +0000 Subject: hash.c: to_proc * hash.c (rb_hash_to_proc): new method Hash#to_proc. [Feature #11653] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_hash.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 4f48d3b90c..cb59524bd0 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1333,6 +1333,16 @@ class TestHash < Test::Unit::TestCase assert_not_operator(h2, :>, h2) end + def test_to_proc + h = { + 1 => 10, + 2 => 20, + 3 => 30, + } + + assert_equal([10, 20, 30], [1, 2, 3].map(&h)) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) -- cgit v1.2.3