[Tests] Migrate backend-independent tests from native to compiler/testData.

^KT-65979
This commit is contained in:
Vladimir Sukharev
2024-02-25 18:25:58 +01:00
committed by Space Team
parent dd9332d9e1
commit febac0dd5f
640 changed files with 68168 additions and 6313 deletions
@@ -0,0 +1,21 @@
// WITH_STDLIB
import kotlin.test.*
import kotlin.contracts.*
open class S
class P(val str: String = "P") : S()
@OptIn(kotlin.contracts.ExperimentalContracts::class)
fun check(actual: Boolean) {
contract { returns() implies actual }
assertTrue(actual)
}
fun box(): String {
val s: S = P()
check(s is P)
assertEquals(s.str, "P")
return "OK"
}
+12
View File
@@ -0,0 +1,12 @@
// WITH_STDLIB
import kotlin.test.*
fun box(): String {
assertEquals("STR", nullableString("str"))
assertEquals("", nullableString(null))
return "OK"
}
private fun nullableString(string: String?): String = if (string.isNullOrBlank()) "" else "STR"
@@ -0,0 +1,10 @@
// WITH_STDLIB
import kotlin.test.*
fun box(): String {
val i: Int? = 1234
requireNotNull(i)
assertEquals(i, 1234)
return "OK"
}
+21
View File
@@ -0,0 +1,21 @@
// WITH_STDLIB
import kotlin.test.*
import kotlin.contracts.*
open class S
class P(val str: String = "P") : S()
@OptIn(kotlin.contracts.ExperimentalContracts::class)
fun check(actual: Boolean) {
contract { returns() implies actual }
assertTrue(actual)
}
fun box(): String {
val s: S = P()
require(s is P)
assertEquals(s.str, "P")
return "OK"
}
@@ -0,0 +1,12 @@
// WITH_STDLIB
import kotlin.test.*
fun box(): String {
val x: Int
run {
x = 42
}
assertEquals(x, 42)
return "OK"
}