diff options
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 15 |
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 |