diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-12-05 06:41:45 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-12-05 06:41:45 +0900 |
| commit | f64ab73b841377f044e727ee1d9e0bcf55c6b626 (patch) | |
| tree | f87a6a2c766791dbe0a6b1dfb6599216b661050f /tests | |
| parent | d31f9ba65586887ac662a86887a8ffe87774081b (diff) | |
| download | ducc-f64ab73b841377f044e727ee1d9e0bcf55c6b626.tar.gz ducc-f64ab73b841377f044e727ee1d9e0bcf55c6b626.tar.zst ducc-f64ab73b841377f044e727ee1d9e0bcf55c6b626.zip | |
feat: minimal wasm backend
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 |
