diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-12-11 21:09:40 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-12-11 21:09:40 +0900 |
| commit | 1908a8898cc2455dddd881a4883ce51bb36f5d8e (patch) | |
| tree | 2abb48d7c722b5c0f60b99fcee2fce64045ed229 /tests | |
| parent | 000f1d7f7412440619112b09f64ff653d960ed25 (diff) | |
| download | ducc-1908a8898cc2455dddd881a4883ce51bb36f5d8e.tar.gz ducc-1908a8898cc2455dddd881a4883ce51bb36f5d8e.tar.zst ducc-1908a8898cc2455dddd881a4883ce51bb36f5d8e.zip | |
This reverts commit 47d43f5a583dc2d474e553afe0cb682d878231b1.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/wasm.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/wasm.sh b/tests/wasm.sh new file mode 100644 index 0000000..d024989 --- /dev/null +++ b/tests/wasm.sh @@ -0,0 +1,25 @@ +cat > main.c <<'EOF' +int add(int a, int b) { + return a + b; +} +EOF + +"$ducc" "${CFLAGS:-}" --wasm -o main.wat main.c + +wat2wasm main.wat -o main.wasm + +cat > main.mjs <<'EOF' +import { readFile } from 'fs/promises'; + +const wasmBuffer = await readFile('./main.wasm'); +const { instance } = await WebAssembly.instantiate(wasmBuffer); + +console.log(instance.exports.add(3, 5)); +EOF +node main.mjs > output + +cat > expected <<'EOF' +8 +EOF + +diff -u expected output |
