/vendor/gems/facets-2.4.5/test/core/hash/test_mash.rb
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
- require 'facets/hash/mash'
- require 'test/unit'
- class TC_Hash_Mash < Test::Unit::TestCase
- def test_mash_inplace!
- a = { :a => 1, :b => 2, :c => 3 }
- e = { :a => 2, :b => 3, :c => 4 }
- a.mash!{ |k,v| { k => v+1 } }
- assert_equal( e, a )
- end
- def test_mash_inplace_again!
- h = {:a=>1,:b=>2,:c=>3}
- h.mash!{ |k,v| [v, v*v] }
- assert_equal( {1=>1, 2=>4, 3=>9}, h )
- end
- end