Sha256: 3e08ae86383452afd752a767db7711b1fff4df37fd4a2a667d1d6bc85332658e
Contents?: true
Size: 1 KB
Versions: 10
Compression:
Stored size: 1 KB
Contents
# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ | # |_|\___||___/\__| # # for lib/facets/hash/update.rb # # Extracted Mon Sep 03 16:23:07 -0700 2007 # w/ Test Extraction Ratchet # require 'facets/hash/update.rb' require 'test/unit' class TestHashUpdate < Test::Unit::TestCase def test_replace_each a = { :a => 1, :b => 2, :c => 3 } e = { :a => 2, :b => 3, :c => 4 } a.replace_each{ |k,v| { k => v+1 } } assert_equal( e, a ) end def test_update_each a = { :a => 1, :b => 2, :c => 3 } e = { :a => 2, :b => 3, :c => 4 } a.update_each{ |k,v| { k => v+1 } } assert_equal( e, a ) end def test_update_keys h = { 'A' => 1, 'B' => 2 } h.update_keys{ |k| k.downcase } assert_equal( { 'a' => 1, 'b' => 2 }, h) end def test_update_values h = { 1 => 'A', 2 => 'B' } h.update_values{ |v| v.downcase } assert_equal( { 1 => 'a', 2 => 'b' }, h ) end end
Version data entries
10 entries across 10 versions & 1 rubygems