[K/N] Move special backend checks test sources to diagnostic tests folder

^KT-61564
This commit is contained in:
Vladimir Sukharev
2023-11-22 19:56:02 +01:00
committed by Space Team
parent 3d0a91bf3c
commit 8f12bf6cc8
67 changed files with 82 additions and 157 deletions
@@ -0,0 +1,11 @@
import kotlinx.cinterop.*
fun foo(x: Int, vararg s: String): Int {
var sum = x
s.forEach { sum += it.length }
return sum
}
fun bar() {
staticCFunction(::foo)
}
@@ -0,0 +1,7 @@
import kotlinx.cinterop.*
fun foo(f: Function1<*, Int>) = f
fun bar() {
staticCFunction(::foo)
}
@@ -0,0 +1,7 @@
import kotlinx.cinterop.*
fun foo(f: Function1<in Int, Int>) = f
fun bar() {
staticCFunction(::foo)
}
@@ -0,0 +1,7 @@
import kotlinx.cinterop.*
fun foo(x: CValue<*>?) = x
fun bar() {
staticCFunction(::foo)
}
@@ -0,0 +1,8 @@
import kotlinx.cinterop.*
fun <T: CVariable> bar() {
fun foo(x: CValue<T>) = x
staticCFunction(::foo)
}
@@ -0,0 +1,9 @@
import kotlinx.cinterop.*
class Z(rawPtr: NativePtr): CStructVar(rawPtr)
fun foo(x: CValue<Z>) = x
fun bar() {
staticCFunction(::foo)
}
@@ -0,0 +1,11 @@
import kotlinx.cinterop.*
import kotlinx.cinterop.internal.*
@CStruct(spelling = "struct { }") class Z constructor(rawPtr: NativePtr) : CStructVar(rawPtr) {
val x: Pair<Int, Int>? = null
@CStruct.MemberAt(offset = 0L) get
}
fun foo(z: Z) = z.x
fun main() { }
@@ -0,0 +1,14 @@
import kotlinx.cinterop.*
import kotlinx.cinterop.internal.*
@CStruct(spelling = "struct { }") class Z constructor(rawPtr: NativePtr) : CStructVar(rawPtr) {
var x: Pair<Int, Int>? = null
@CStruct.MemberAt(offset = 0L) get
@CStruct.MemberAt(offset = 0L) set
}
fun foo(z: Z) {
z.x = 42 to 117
}
fun main() { }
@@ -0,0 +1,9 @@
import kotlinx.cinterop.*
class Z {
fun foo(x: Int) = x
}
fun bar() {
staticCFunction(Z()::foo)
}
@@ -0,0 +1,8 @@
import kotlinx.cinterop.*
fun bar(x: Int) {
fun foo() = x
staticCFunction(::foo)
}
@@ -0,0 +1,7 @@
import kotlinx.cinterop.*
fun foo(x: Any) = x
fun bar() {
staticCFunction<String, Any>(::foo)
}
@@ -0,0 +1,3 @@
import kotlinx.cinterop.*
fun bar(x: Float) = x.signExtend<Int>()
@@ -0,0 +1,3 @@
import kotlinx.cinterop.*
fun bar(x: Int) = x.signExtend<Float>()
@@ -0,0 +1,3 @@
import kotlinx.cinterop.*
fun bar(x: Int) = x.signExtend<Short>()
@@ -0,0 +1,3 @@
import kotlinx.cinterop.*
fun bar(x: Int) = x.narrow<Long>()
@@ -0,0 +1,3 @@
import kotlinx.cinterop.*
fun bar(x: Int) = x.convert<String>()
@@ -0,0 +1,10 @@
import kotlinx.cinterop.*
class Vertex constructor(rawPtr: NativePtr) : CStructVar(rawPtr) {
var x: Float = 0f
var y: Float = 0f
var r: Float = 0f
var g: Float = 0f
var b: Float = 0f
companion object : CStructVar.Type(40, 8)
}
@@ -0,0 +1,30 @@
import kotlinx.cinterop.*
import kotlin.coroutines.*
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
companion object : EmptyContinuation()
override fun resumeWith(result: Result<Any?>) { result.getOrThrow() }
}
lateinit var continuation: Continuation<Unit>
suspend fun suspendHere(): Unit = suspendCoroutine { cont ->
continuation = cont
}
fun startCoroutine(block: suspend () -> Unit) {
block.startCoroutine(EmptyContinuation)
}
fun main() {
autoreleasepool {
startCoroutine {
autoreleasepool {
suspendHere()
}
}
}
continuation.resume(Unit)
}
@@ -0,0 +1,32 @@
import kotlinx.cinterop.*
import kotlin.coroutines.*
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
companion object : EmptyContinuation()
override fun resumeWith(result: Result<Any?>) { result.getOrThrow() }
}
lateinit var continuation: Continuation<Unit>
suspend fun suspendHere(): Unit = suspendCoroutine { cont ->
continuation = cont
}
fun startCoroutine(block: suspend () -> Unit) {
block.startCoroutine(EmptyContinuation)
}
inline fun <T> myAutoreleasepool(block: () -> T) = autoreleasepool(block)
fun main() {
autoreleasepool {
startCoroutine {
myAutoreleasepool {
suspendHere()
}
}
}
continuation.resume(Unit)
}
@@ -0,0 +1,7 @@
import kotlinx.cinterop.*
fun foo(f: Function0<*>) = f
fun bar() {
staticCFunction(::foo)
}
@@ -0,0 +1,7 @@
import kotlinx.cinterop.*
fun foo(f: Function0<out Int>) = f
fun bar() {
staticCFunction(::foo)
}