Files
kotlin-fork/libraries/stdlib/test/testUtils.kt
T
Ilya Gorbunov 053f3b6ac0 Tests: use helper function to assert compile-time and run-time type check
To cleanup warnings about useless cast or type check that is always true.
2017-12-26 04:55:44 +03:00

14 lines
384 B
Kotlin

package test
import kotlin.internal.NoInfer
import kotlin.test.fail
// just a static type check
fun <T> assertStaticTypeIs(@Suppress("UNUSED_PARAMETER") value: @NoInfer T) {}
inline fun <reified T> assertStaticAndRuntimeTypeIs(value: @NoInfer T) {
@Suppress("USELESS_CAST")
if ((value as Any?) !is T) {
fail("Expected value $value to have ${T::class} type")
}
}