mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 22:45:03 +02:00
* 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:
parent
57d596cdb4
commit
55fb13eff9
2 changed files with 21 additions and 12 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue