diff options
author | Paul Barry <mail@paulbarry.com> | 2010-06-11 23:28:09 -0400 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-06-13 04:19:35 +0200 |
commit | 9183eaebed19f75980926fad2f3655f5f5e7826c (patch) | |
tree | fe88b7c20142f7ecb8ed21ea5127241287e92e37 /activesupport | |
parent | 58e21a4a0d4eefc395139e88c1f184b9eaf0b4c4 (diff) | |
download | rails-9183eaebed19f75980926fad2f3655f5f5e7826c.tar.gz rails-9183eaebed19f75980926fad2f3655f5f5e7826c.tar.bz2 rails-9183eaebed19f75980926fad2f3655f5f5e7826c.zip |
re-organized test for merge into separate tests
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/ordered_hash_test.rb | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 66e727007a..56369585ec 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -141,23 +141,31 @@ class OrderedHashTest < Test::Unit::TestCase merged = @ordered_hash.merge other_hash assert_equal merged.length, @ordered_hash.length + other_hash.length assert_equal @keys + ['purple', 'violet'], merged.keys + end - another_hash = ActiveSupport::OrderedHash.new - another_hash['white'] = 'ff' - another_hash['black'] = '00' - merged_with_block = @ordered_hash.merge(another_hash) do |key, old_value, new_value| + 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 end - assert_equal 'ffffff', merged_with_block['white'] - assert_equal '000000', merged_with_block['black'] + assert_equal 'ffffff', merged['white'] + assert_equal '000000', merged['black'] - @ordered_hash.merge! other_hash - assert_equal @ordered_hash, merged - assert_equal @ordered_hash.keys, merged.keys + assert_nil @ordered_hash['white'] + assert_nil @ordered_hash['black'] + end - @ordered_hash.merge! another_hash - assert_equal 'ffffff', merged_with_block['white'] - assert_equal '000000', merged_with_block['black'] + 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 + end + assert_equal 'ffffff', @ordered_hash['white'] + assert_equal '000000', @ordered_hash['black'] end def test_shift @@ -165,7 +173,7 @@ class OrderedHashTest < Test::Unit::TestCase assert_equal [@keys.first, @values.first], pair assert !@ordered_hash.keys.include?(pair.first) end - + def test_keys original = @ordered_hash.keys.dup @ordered_hash.keys.pop |