OrderedHash#select now preserves order [#5843 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
James A. Rosen
2010-10-20 08:01:02 -07:00
committed by Santiago Pastorino
parent 990f52ebd7
commit 697f4851b8
2 changed files with 10 additions and 0 deletions

View File

@@ -137,6 +137,8 @@ module ActiveSupport
alias_method :each_pair, :each
alias_method :select, :find_all
def clear
super
@keys.clear

View File

@@ -109,6 +109,14 @@ class OrderedHashTest < Test::Unit::TestCase
assert_equal @keys, keys
end
def test_find_all
assert_equal @keys, @ordered_hash.find_all { true }.map(&:first)
end
def test_select
assert_equal @keys, @ordered_hash.select { true }.map(&:first)
end
def test_delete_if
copy = @ordered_hash.dup
copy.delete('pink')