diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 17:10:50 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 17:10:50 +0000 |
commit | 55fb13eff9dbc5c0565dfb75d6a4e919af00e696 (patch) | |
tree | fe21039327202df004b042da968c181f6c3fa24f /test/ruby/test_enumerator.rb | |
parent | 57d596cdb4a0de82288e3f526126ddf23fff0c41 (diff) | |
download | ruby-55fb13eff9dbc5c0565dfb75d6a4e919af00e696.tar.gz |
* 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
Diffstat (limited to 'test/ruby/test_enumerator.rb')
-rw-r--r-- | test/ruby/test_enumerator.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index 3143be21a0..c276455a01 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -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 |