Fix infinite sequence being terminated prematurely when being iterated without calling hasNext

#KT-16922 Fixed
This commit is contained in:
Ilya Gorbunov
2017-03-17 23:17:28 +03:00
parent f00ab135d6
commit e5a28311bc
2 changed files with 33 additions and 9 deletions
@@ -287,4 +287,19 @@ class SequenceBuilderTest {
effects.toList()
)
}
@Test
fun testInfiniteYieldAll() {
val values = buildIterator {
while (true) {
yieldAll((1..5).map { it })
}
}
var sum = 0
repeat(10) {
sum += values.next() //.also(::println)
}
assertEquals(30, sum)
}
}