Make size on an infinite each_slice enumerator return Infinity

Fixes [Bug #15889]
This commit is contained in:
Jeremy Evans 2019-06-02 20:00:35 -07:00
parent f48aad7ba2
commit 17af8bfce6
2 changed files with 10 additions and 0 deletions

View file

@ -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)