tests: Copy stdlib tests from Kotlin/JVM
This patch copies Kotlin/JVM stdlib tests (libraries/stdlib/test) excepting ones with explicit java dependencies. It also transforms the tests to use them as box-tests.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.comparisons.*
|
||||
|
||||
fun fibonacci(): Sequence<Int> {
|
||||
// fibonacci terms
|
||||
// 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, ...
|
||||
return generateSequence(Pair(0, 1), { Pair(it.second, it.first + it.second) }).map { it.first }
|
||||
}
|
||||
|
||||
fun box() {
|
||||
assertEquals("233, 377, 610", fibonacci().dropWhile { it < 200 }.take(3).joinToString(limit = 10))
|
||||
assertEquals("", sequenceOf(1).dropWhile { it < 200 }.joinToString(limit = 10))
|
||||
}
|
||||
Reference in New Issue
Block a user