[Wasm] Test infra: support _commonFiles and additional .mjs

Use custom `evalToBoolean` as `eval` and `unsafeCast` are not
 available in Wasm stdlib
This commit is contained in:
Svyatoslav Kuzmich
2023-01-11 12:59:52 +01:00
committed by Space Team
parent 80e07d628b
commit fd67464d14
3 changed files with 13 additions and 3 deletions
+4 -1
View File
@@ -1,6 +1,9 @@
package testUtils
@JsName("eval")
private external fun evalToBoolean(code: String): Boolean
fun isLegacyBackend(): Boolean =
// Using eval to prevent DCE from thinking that following code depends on Kotlin module.
eval("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")").unsafeCast<Boolean>()
evalToBoolean("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")")