diff options
author | Xavier Noria <fxn@hashref.com> | 2010-06-13 06:37:54 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-06-13 06:37:54 +0200 |
commit | 36143d26cb841210b5f22aff4ed9c093a0554a1a (patch) | |
tree | 751e2da1787259986a93e50beee08cf6fab406cd /activesupport/test | |
parent | 3359af63a518798ccc9c7f1c71e5507f6fe0d378 (diff) | |
download | rails-36143d26cb841210b5f22aff4ed9c093a0554a1a.tar.gz rails-36143d26cb841210b5f22aff4ed9c093a0554a1a.tar.bz2 rails-36143d26cb841210b5f22aff4ed9c093a0554a1a.zip |
revises implementation of AS::OrderedHash#merge!
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 56369585ec..0f36f5204d 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -144,28 +144,29 @@ class OrderedHashTest < Test::Unit::TestCase end def test_merge_with_block - other_hash = ActiveSupport::OrderedHash.new - other_hash['white'] = 'ff' - other_hash['black'] = '00' - merged = @ordered_hash.merge(other_hash) do |key, old_value, new_value| - new_value * 3 + hash = ActiveSupport::OrderedHash.new + hash[:a] = 0 + hash[:b] = 0 + merged = hash.merge(:b => 2, :c => 7) do |key, old_value, new_value| + new_value + 1 end - assert_equal 'ffffff', merged['white'] - assert_equal '000000', merged['black'] - assert_nil @ordered_hash['white'] - assert_nil @ordered_hash['black'] + assert_equal 0, merged[:a] + assert_equal 3, merged[:b] + assert_equal 7, merged[:c] end def test_merge_bang_with_block - other_hash = ActiveSupport::OrderedHash.new - other_hash['white'] = 'ff' - other_hash['black'] = '00' - @ordered_hash.merge!(other_hash) do |key, old_value, new_value| - new_value * 3 + hash = ActiveSupport::OrderedHash.new + hash[:a] = 0 + hash[:b] = 0 + hash.merge!(:a => 1, :c => 7) do |key, old_value, new_value| + new_value + 3 end - assert_equal 'ffffff', @ordered_hash['white'] - assert_equal '000000', @ordered_hash['black'] + + assert_equal 4, hash[:a] + assert_equal 0, hash[:b] + assert_equal 7, hash[:c] end def test_shift |