PageRenderTime 60ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 20 lines | 15 code | 5 blank | 0 comment | 0 complexity | c30dff7f14337dfe37c5ea8c38efc9fc 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/mash'
  2. require 'test/unit'
  3. class TC_Hash_Mash < Test::Unit::TestCase
  4. def test_mash_inplace!
  5. a = { :a => 1, :b => 2, :c => 3 }
  6. e = { :a => 2, :b => 3, :c => 4 }
  7. a.mash!{ |k,v| { k => v+1 } }
  8. assert_equal( e, a )
  9. end
  10. def test_mash_inplace_again!
  11. h = {:a=>1,:b=>2,:c=>3}
  12. h.mash!{ |k,v| [v, v*v] }
  13. assert_equal( {1=>1, 2=>4, 3=>9}, h )
  14. end
  15. end