[FE] Fix tests

This commit is contained in:
Victor Petukhov
2022-04-22 14:02:43 +03:00
committed by teamcity
parent 12a39d0330
commit 0f1d212fc5
20 changed files with 201 additions and 108 deletions
-12
View File
@@ -1,12 +0,0 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
fun box(): String {
return try {
val range1 = 0..1
range1 as List<Double>
range1.joinToString { "" }
} catch (e: java.lang.ClassCastException) {
"OK"
}
}
@@ -1,41 +0,0 @@
// !LANGUAGE: +SuspendConversion
// WITH_STDLIB
// WITH_COROUTINES
// IGNORE_BACKEND: JVM, NATIVE, JS, JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: IGNORED_IN_JS
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun useSuspendFun(fn : suspend () -> String) = fn()
suspend fun useSuspendFunInt(fn: suspend (Int) -> String) = fn(42)
suspend fun <T> testIntersection(x: T): String where T : () -> String, T : (Int) -> String {
val a = useSuspendFun(x)
val b = useSuspendFunInt(x)
return a + b
}
class Test : () -> String, (Int) -> String {
override fun invoke(): String = "OKEmpty"
override fun invoke(p: Int) = "OK$p"
}
fun box(): String {
var test = "Failed"
builder {
test = testIntersection(Test())
}
if (test != "OKEmptyOK42") return "failed: $test"
return "OK"
}
@@ -1,41 +0,0 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: IGNORED_IN_JS
// IGNORE_BACKEND: JS, JS_IR
// IGNORE_BACKEND: JS_IR_ES6
fun interface KRunnable {
fun invoke()
}
fun interface KBoolean {
fun invoke(b: Boolean)
}
fun useFunInterface(fn: KRunnable) {
fn.invoke()
}
fun useFunInterfacePredicate(fn: KBoolean) {
fn.invoke(true)
}
fun <T> testIntersection(x: T) where T : () -> Unit, T : (Boolean) -> Unit {
useFunInterface(x)
useFunInterfacePredicate(x)
}
var result = ""
object Test : () -> Unit, (Boolean) -> Unit {
override fun invoke() {
result += "O"
}
override fun invoke(p1: Boolean) {
if (p1) result += "K"
}
}
fun box(): String {
testIntersection(Test)
return result
}