mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
Make size on an infinite each_slice enumerator return Infinity
Fixes [Bug #15889]
This commit is contained in:
parent
f48aad7ba2
commit
17af8bfce6
2 changed files with 10 additions and 0 deletions
|
@ -113,6 +113,11 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
assert_equal([[1,2,3],[4,5,6],[7,8,9],[10]], (1..10).each_slice(3).to_a)
|
||||
end
|
||||
|
||||
def test_each_slice_size
|
||||
assert_equal(4, (1..10).each_slice(3).size)
|
||||
assert_equal(Float::INFINITY, 1.step.each_slice(3).size)
|
||||
end
|
||||
|
||||
def test_cons
|
||||
a = [[1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9,10]]
|
||||
assert_equal(a, (1..10).each_cons(3).to_a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue