/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

  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