* array.c: Support for Enumerator#size in trivial cases:

each, each_index, reverse_each, sort_by, collect,
  collect!, select, select!, keep_if, reject, reject!, delete_if
  [Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2012-11-06 17:10:50 +00:00
parent 57d596cdb4
commit 55fb13eff9
2 changed files with 21 additions and 12 deletions

View file

@ -420,5 +420,14 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal 42, enum.with_index.size
assert_equal 42, enum.with_object(:foo).size
end
def test_size_for_enum_created_from_array
arr = %w[hello world]
%i[each each_with_index reverse_each sort_by! sort_by map map!
keep_if reject! reject select! select delete_if].each do |method|
assert_equal arr.size, arr.send(method).size
end
end
end