Files
kotlin-fork/libraries/stdlib/test/collections/SequenceJVMTest.kt
T
Ilya Gorbunov 20b122c1dd Use kotlin.test.Test instead of org.junit.Test in common stdlib tests
(and in jvm-only and js-only tests also)
2017-10-15 17:40:53 +03:00

27 lines
875 B
Kotlin

@file:kotlin.jvm.JvmVersion
package test.collections
import kotlin.test.*
class SequenceJVMTest {
@Test fun filterIsInstance() {
val src: Sequence<Any> = listOf(1, 2, 3.toDouble(), "abc", "cde").asSequence()
val intValues: Sequence<Int> = src.filterIsInstance<Int>()
assertEquals(listOf(1, 2), intValues.toList())
val doubleValues: Sequence<Double> = src.filterIsInstance<Double>()
assertEquals(listOf(3.0), doubleValues.toList())
val stringValues: Sequence<String> = src.filterIsInstance<String>()
assertEquals(listOf("abc", "cde"), stringValues.toList())
val anyValues: Sequence<Any> = src.filterIsInstance<Any>()
assertEquals(src.toList(), anyValues.toList())
val charValues: Sequence<Char> = src.filterIsInstance<Char>()
assertEquals(0, charValues.toList().size)
}
}