[K/N] Move special backend checks test sources to diagnostic tests folder
^KT-61564
This commit is contained in:
committed by
Space Team
parent
3d0a91bf3c
commit
8f12bf6cc8
+11
@@ -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)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun foo(f: Function1<*, Int>) = f
|
||||
|
||||
fun bar() {
|
||||
staticCFunction(::foo)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun foo(f: Function1<in Int, Int>) = f
|
||||
|
||||
fun bar() {
|
||||
staticCFunction(::foo)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun foo(x: CValue<*>?) = x
|
||||
|
||||
fun bar() {
|
||||
staticCFunction(::foo)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun <T: CVariable> bar() {
|
||||
|
||||
fun foo(x: CValue<T>) = x
|
||||
|
||||
staticCFunction(::foo)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
class Z(rawPtr: NativePtr): CStructVar(rawPtr)
|
||||
|
||||
fun foo(x: CValue<Z>) = x
|
||||
|
||||
fun bar() {
|
||||
staticCFunction(::foo)
|
||||
}
|
||||
+11
@@ -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() { }
|
||||
+14
@@ -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() { }
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
class Z {
|
||||
fun foo(x: Int) = x
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
staticCFunction(Z()::foo)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun bar(x: Int) {
|
||||
|
||||
fun foo() = x
|
||||
|
||||
staticCFunction(::foo)
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun foo(x: Any) = x
|
||||
|
||||
fun bar() {
|
||||
staticCFunction<String, Any>(::foo)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun bar(x: Float) = x.signExtend<Int>()
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun bar(x: Int) = x.signExtend<Float>()
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun bar(x: Int) = x.signExtend<Short>()
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun bar(x: Int) = x.narrow<Long>()
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun bar(x: Int) = x.convert<String>()
|
||||
+10
@@ -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)
|
||||
}
|
||||
+30
@@ -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)
|
||||
}
|
||||
+32
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user