Allow dropping and taking a lot of elements in very long sequences
For example allow dropping and taking Int.MAX_VALUE elements from a sequence that is a result of another Int.MAX_VALUE dropping.
This commit is contained in:
@@ -41,5 +41,21 @@ class IndexOverflowJVMTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
fun dropTwiceMaxValue() {
|
||||
|
||||
val halfMax = (1 shl 30) + 1
|
||||
|
||||
val dropOnce = longCountSequence.drop(halfMax)
|
||||
val dropTwice = dropOnce.drop(halfMax)
|
||||
|
||||
val expectedEnd = halfMax.toLong() * 2
|
||||
|
||||
assertEquals(expectedEnd, dropTwice.first())
|
||||
|
||||
val dropTake = dropOnce.take(halfMax + 1)
|
||||
|
||||
assertEquals(expectedEnd, dropTake.last())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user