summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-23 15:10:48 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-23 15:10:48 +0000
commitdc215dcd9f96620b7c06a25a741d13b19c2f130b (patch)
tree760deacf8def453cd813b896dbac2b2927f85cf0 /test/ruby/test_array.rb
parent57e52dea773cd51ed943ae1df142f65b725103a3 (diff)
* array.c: Add Array#to_h [Feature #7292]
* enum.c: Add Enumerable#to_h git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index f4faa9bedc..d7e1c365dd 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1456,6 +1456,21 @@ class TestArray < Test::Unit::TestCase
$, = nil
end
+ def test_to_h
+ kvp = Object.new
+ def kvp.to_ary
+ [:obtained, :via_to_ary]
+ end
+ array = [
+ [:key, :value],
+ [:ignore_me],
+ [:ignore, :me, :too],
+ :ignore_me,
+ kvp,
+ ]
+ assert_equal({key: :value, obtained: :via_to_ary}, array.to_h)
+ end
+
def test_uniq
a = []
b = a.uniq