[Wasm] add simple tests to track the size of wasm and mjs files

This commit is contained in:
Zalim Bashorov
2023-03-29 01:34:38 +02:00
parent 1697a28bf0
commit 6e3eef7a88
19 changed files with 244 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 146_294
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 8_247
// FILE: test.kt
@JsExport
fun add(a: Int, b: Int) = a + b
// FILE: entry.mjs
import k from "./index.mjs"
const r = k.add(2, 3);
if (r != 5) throw Error("Wrong result: " + r);
+9
View File
@@ -0,0 +1,9 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 146_626
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 8_188
fun box(): String {
println("Hello, World!")
return "OK"
}
+20
View File
@@ -0,0 +1,20 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 149_186
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 8_686
// FILE: test.kt
import kotlinx.browser.document
import kotlinx.dom.appendText
@JsExport
fun test() {
document.body?.appendText("Hello, World!")
}
// FILE: entry.mjs
import k from "./index.mjs"
const r = typeof k.test;
if (r != "function") throw Error("Wrong result: " + r);
+6
View File
@@ -0,0 +1,6 @@
// TARGET_BACKEND: WASM
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 146_345
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 8_119
fun box() = "OK"