diff options
Diffstat (limited to 'cli/tests/051_wasm_import')
-rw-r--r-- | cli/tests/051_wasm_import/remote.ts | 3 | ||||
-rw-r--r-- | cli/tests/051_wasm_import/simple.wasm | bin | 0 -> 226 bytes | |||
-rw-r--r-- | cli/tests/051_wasm_import/simple.wat | 31 | ||||
-rw-r--r-- | cli/tests/051_wasm_import/wasm-dep.js | 17 |
4 files changed, 51 insertions, 0 deletions
diff --git a/cli/tests/051_wasm_import/remote.ts b/cli/tests/051_wasm_import/remote.ts new file mode 100644 index 000000000..761a5248e --- /dev/null +++ b/cli/tests/051_wasm_import/remote.ts @@ -0,0 +1,3 @@ +export function jsRemoteFn(): number { + return 2019; +} diff --git a/cli/tests/051_wasm_import/simple.wasm b/cli/tests/051_wasm_import/simple.wasm Binary files differnew file mode 100644 index 000000000..8e544fe30 --- /dev/null +++ b/cli/tests/051_wasm_import/simple.wasm diff --git a/cli/tests/051_wasm_import/simple.wat b/cli/tests/051_wasm_import/simple.wat new file mode 100644 index 000000000..5e73db97b --- /dev/null +++ b/cli/tests/051_wasm_import/simple.wat @@ -0,0 +1,31 @@ +;; From https://github.com/nodejs/node/blob/bbc254db5db672643aad89a436a4938412a5704e/test/fixtures/es-modules/simple.wat +;; MIT Licensed +;; $ wat2wasm simple.wat -o simple.wasm + +(module + (import "./wasm-dep.js" "jsFn" (func $jsFn (result i32))) + (import "./wasm-dep.js" "jsInitFn" (func $jsInitFn)) + (import "http://127.0.0.1:4545/cli/tests/051_wasm_import/remote.ts" "jsRemoteFn" (func $jsRemoteFn (result i32))) + (export "add" (func $add)) + (export "addImported" (func $addImported)) + (export "addRemote" (func $addRemote)) + (start $startFn) + (func $startFn + call $jsInitFn + ) + (func $add (param $a i32) (param $b i32) (result i32) + local.get $a + local.get $b + i32.add + ) + (func $addImported (param $a i32) (result i32) + local.get $a + call $jsFn + i32.add + ) + (func $addRemote (param $a i32) (result i32) + local.get $a + call $jsRemoteFn + i32.add + ) +) diff --git a/cli/tests/051_wasm_import/wasm-dep.js b/cli/tests/051_wasm_import/wasm-dep.js new file mode 100644 index 000000000..70b16348b --- /dev/null +++ b/cli/tests/051_wasm_import/wasm-dep.js @@ -0,0 +1,17 @@ +function assertEquals(actual, expected, msg) { + if (actual !== expected) { + throw new Error(msg || ""); + } +} + +export function jsFn() { + state = "WASM JS Function Executed"; + return 42; +} + +export let state = "JS Function Executed"; + +export function jsInitFn() { + assertEquals(state, "JS Function Executed", "Incorrect state"); + state = "WASM Start Executed"; +} |