diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 17:12:35 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 17:12:35 +0000 |
commit | c82ad6d20781630c9bf71fd811cade770691240e (patch) | |
tree | ab9126bba97d1b086d74721c49cdf6d45572279e /test/ruby/test_enumerator.rb | |
parent | 727024fbac6ac97a3c4236583e5819d72a1513b7 (diff) | |
download | ruby-c82ad6d20781630c9bf71fd811cade770691240e.tar.gz |
* enum.c: Support for enumerators created by Enumerable with forwarding:
find_all, reject, ...
[Feature #6636]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_enumerator.rb')
-rw-r--r-- | test/ruby/test_enumerator.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index b2ef8e5c25..4757855533 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -10,6 +10,10 @@ class TestEnumerator < Test::Unit::TestCase a.each {|x| yield x } end end + @sized = @obj.clone + def @sized.size + 42 + end end def enum_test obj @@ -429,6 +433,16 @@ class TestEnumerator < Test::Unit::TestCase end end + def test_size_for_enum_created_from_enumerable + %i[find_all reject map flat_map partition group_by sort_by min_by max_by + minmax_by each_with_index reverse_each each_entry].each do |method| + assert_equal nil, @obj.send(method).size + assert_equal 42, @sized.send(method).size + end + assert_equal nil, @obj.each_with_object(nil).size + assert_equal 42, @sized.each_with_object(nil).size + end + def check_consistency_for_combinatorics(method) [ [], [:a, :b, :c, :d, :e] ].product([-2, 0, 2, 5, 6]) do |array, arg| assert_equal array.send(method, arg).to_a.size, array.send(method, arg).size, |