diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-22 11:23:56 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-22 11:23:56 +0000 |
commit | 8717f0787df49080d742c366bb8e70c7527ef6bd (patch) | |
tree | 6e7b84ed7b531adfab25916bb6762b1e79b5ec42 /test/ruby | |
parent | d96483de720f6a54292b15fea2458befa02a3ffa (diff) | |
download | ruby-8717f0787df49080d742c366bb8e70c7527ef6bd.tar.gz |
Set the size of a new enumerator created by Enumerator#each with arguments to nil
When each() takes arguments, it is never safe to assume that the iteration
would repeat the same number of times as with each() without any
argument. Actually, there is no way to get the exact number, so the
size should be set to nil to denote that.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_enumerator.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index a24ff00d96..0839c2c3dd 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -301,8 +301,11 @@ class TestEnumerator < Test::Unit::TestCase yield end ary = [] - e = o.to_enum.each(ary) - e.next + e = o.to_enum { 1 } + assert_equal(1, e.size) + e_arg = e.each(ary) + assert_equal(nil, e_arg.size) + e_arg.next assert_equal([1], ary) end |