[K/N][tests] Migrate link tests to new testing infra ^KT-61259
This commit is contained in:
committed by
Space Team
parent
588549d1d0
commit
d6a922bc74
@@ -0,0 +1,18 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package a
|
||||
|
||||
inline fun foo(x: Int, y: Int = 117) = x + y
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import a.*
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(122, foo(5))
|
||||
assertEquals(47, foo(5, 42))
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package a
|
||||
|
||||
fun foo(n: Int, block: (Int) -> Int): Int {
|
||||
val arr = IntArray(n) { block(it) }
|
||||
var sum = 0
|
||||
for (x in arr) sum += x
|
||||
return sum
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import a.*
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(42, foo(7) { it * 2 })
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package a
|
||||
|
||||
class E(val x: String) {
|
||||
inner class Inner {
|
||||
inline fun foo(y: String) = x + y
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String {
|
||||
return E("O").Inner().foo("K")
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// KT-64511: lateinit is not lowered with caches
|
||||
// DISABLE_NATIVE: cacheMode=STATIC_EVERYWHERE
|
||||
// DISABLE_NATIVE: cacheMode=STATIC_PER_FILE_EVERYWHERE
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package a
|
||||
|
||||
fun IntArray.forEachNoInline(block: (Int) -> Unit) = this.forEach { block(it) }
|
||||
|
||||
inline fun foo(values: IntArray, crossinline block: (Int, Int, Int) -> Int): Int {
|
||||
val o = object {
|
||||
lateinit var s: String
|
||||
var x: Int = 42
|
||||
}
|
||||
values.forEachNoInline {
|
||||
o.x = block(o.x, o.s.length, it)
|
||||
}
|
||||
return o.x
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||
|
||||
import a.*
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<UninitializedPropertyAccessException> {
|
||||
foo(intArrayOf(1, 2, 3)) { x, y, z -> x + y - z }
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package a
|
||||
|
||||
fun IntArray.forEachNoInline(block: (Int) -> Unit) = this.forEach { block(it) }
|
||||
|
||||
inline fun fold(initial: Int, values: IntArray, crossinline block: (Int, Int) -> Int): Int {
|
||||
var res = initial
|
||||
values.forEachNoInline {
|
||||
res = block(res, it)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import a.*
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(6, fold(0, intArrayOf(1, 2, 3)) { x, y -> x + y })
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user