Files
kotlin-fork/js/js.translator/testData/box/native/passTopLevelOrLocalFunctionToNative.kt
T
Zalim Bashorov b02279de14 [Wasm] Run wasm test using all available VMs: V8 & SpiderMonkey for now
Also, add a new directive, `WASM_FAILS_IN`, to specify VMs where a test is expected to fail for now.

#KT-56166 Fixed
2023-01-27 17:57:50 +01:00

23 lines
584 B
Kotlin
Vendored

// WASM_FAILS_IN: SM
// EXPECTED_REACHABLE_NODES: 1284
package foo
external fun run(i:Int, s:String, funRef: (Int, String) -> String): String = definedExternally
fun funTopLevel(i:Int, s:String): String = "funTopLevel $i $s"
fun box(): String {
fun funLocal(i:Int, s:String): String = "funLocal $i $s"
// Check for lambda
var r = run(4, "boo") { i, s -> "$i $s"}
if (r != "4 boo") return r
r = run(4, "boo", ::funTopLevel)
if (r != "funTopLevel 4 boo") return r
r = run(4, "boo", ::funLocal)
if (r != "funLocal 4 boo") return r
return "OK"
}