Fix infinite sequence being terminated prematurely when being iterated without calling hasNext
#KT-16922 Fixed
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user