PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/hash/test_traverse.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 22 lines | 17 code | 5 blank | 0 comment | 0 complexity | 89a2ffe8a4bb4eb019f243ed854b7c7c MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. require 'facets/hash/traverse'
  2. require 'test/unit'
  3. class TC_Hash_Traverse < Test::Unit::TestCase
  4. def test_traverse
  5. h = { "A" => "x", "B" => "y" }
  6. h2 = h.traverse { |k,v| [k.downcase, v.upcase] }
  7. e = { "a" => "X", "b" => "Y" }
  8. assert_not_equal( h, h2 )
  9. assert_equal( e, h2 )
  10. end
  11. def test_traverse!
  12. h = { "A" => "x", "B" => "y" }
  13. h.traverse! { |k,v| [k.downcase, v.upcase] }
  14. e = { "a" => "X", "b" => "Y" }
  15. assert_equal( e, h )
  16. end
  17. end