mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
* enumerator.c: Support #size for enumerators created from enumerators
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
acfd34a6a9
commit
57d596cdb4
2 changed files with 11 additions and 2 deletions
|
@ -414,5 +414,11 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
assert_equal nil, @obj.to_enum(:foo, 0, 1).size
|
||||
assert_equal 2, @obj.to_enum(:foo, 0, 1){ 2 }.size
|
||||
end
|
||||
|
||||
def test_size_for_enum_created_by_enumerators
|
||||
enum = to_enum{ 42 }
|
||||
assert_equal 42, enum.with_index.size
|
||||
assert_equal 42, enum.with_object(:foo).size
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue