mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
* enumerator: New method #size; constructor accepts size
[Feature #6636] * include/ruby/intern.h: RETURN_SIZED_ENUMERATOR for support of sized enumerators git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2f4769a874
commit
610eeffa46
3 changed files with 74 additions and 14 deletions
|
@ -401,5 +401,15 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
|
||||
assert_raise(LocalJumpError) { Enumerator::Yielder.new }
|
||||
end
|
||||
|
||||
def test_size
|
||||
assert_equal nil, Enumerator.new{}.size
|
||||
assert_equal 42, Enumerator.new(->{42}){}.size
|
||||
assert_equal 42, Enumerator.new(42){}.size
|
||||
assert_equal 1 << 70, Enumerator.new(1 << 70){}.size
|
||||
assert_equal Float::INFINITY, Enumerator.new(Float::INFINITY){}.size
|
||||
assert_equal nil, Enumerator.new(nil){}.size
|
||||
assert_raise(TypeError) { Enumerator.new("42"){} }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue