Files
kotlin-fork/backend.native/tests/external/stdlib/utils/TODOTest/usage.kt
T
Ilya Matveev 85827b4880 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.
2017-04-07 17:21:11 +07:00

46 lines
1.2 KiB
Kotlin

import kotlin.*
import kotlin.test.*
private class PartiallyImplementedClass {
public val prop: String get() = TODO()
fun method1() = TODO() as String
public fun method2(): Int = TODO()
public fun method3(switch: Boolean, value: String): String {
if (!switch)
TODO("what if false")
else {
if (value.length < 3)
throw TODO("write message")
}
return value
}
public fun method4() {
TODO()
}
}
private fun assertNotImplemented(block: () -> Unit) {
assertFailsWith<NotImplementedError>(block = block)
}
private fun assertNotImplementedWithMessage(message: String, block: () -> Unit) {
val e = assertFailsWith<NotImplementedError>(block = block)
assertTrue(message in e.message!!)
}
fun box() {
val inst = PartiallyImplementedClass()
assertNotImplemented { inst.prop }
assertNotImplemented { inst.method1() }
assertNotImplemented { inst.method2() }
assertNotImplemented { inst.method4() }
assertNotImplementedWithMessage("what if false") { inst.method3(false, "test") }
assertNotImplementedWithMessage("write message") { inst.method3(true, "t") }
assertEquals("test", inst.method3(true, "test"))
}