Add a class for long-running sequence/iterable tests
These tests will not run neither locally nor on CI unless the explicit "kotlin.stdlib.test.long.sequences" parameter is specified.
This commit is contained in:
@@ -261,4 +261,10 @@ compileTestKotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
if (project.hasProperty("kotlin.stdlib.test.long.sequences")) {
|
||||||
|
systemProperty("kotlin.stdlib.test.long.sequences", "true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
kotlin.experimental.coroutines 'enable'
|
kotlin.experimental.coroutines 'enable'
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package test.collections
|
||||||
|
|
||||||
|
import org.junit.Assume
|
||||||
|
import org.junit.Test
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
class IndexOverflowJVMTest {
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
fun checkIsNotIgnored() {
|
||||||
|
Assume.assumeTrue(System.getProperty("kotlin.stdlib.test.long.sequences")?.toBoolean() ?: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun <T> repeatCounted(value: T, count: Long = Int.MAX_VALUE + 1L): Sequence<T> = Sequence {
|
||||||
|
object : Iterator<T> {
|
||||||
|
var counter = count
|
||||||
|
override fun hasNext(): Boolean = counter > 0
|
||||||
|
override fun next(): T = value.also { counter-- }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val maxIndexSequence = repeatCounted("k", (Int.MAX_VALUE + 1L) + 1L) // here the last index is one greater than Int.MAX_VALUE
|
||||||
|
val maxIndexIterable = maxIndexSequence.asIterable()
|
||||||
|
|
||||||
|
|
||||||
|
val longCountSequence = Sequence {
|
||||||
|
object : Iterator<Long> {
|
||||||
|
var counter = 0L
|
||||||
|
override fun hasNext(): Boolean = true
|
||||||
|
override fun next(): Long = counter++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user