]> git.lizzy.rs Git - rust.git/blob - src/test/run-make/wasm-abi/foo.js
:arrow_up: rust-analyzer
[rust.git] / src / test / run-make / wasm-abi / foo.js
1 const fs = require('fs');
2 const process = require('process');
3 const assert = require('assert');
4 const buffer = fs.readFileSync(process.argv[2]);
5
6 const m = new WebAssembly.Module(buffer);
7 const i = new WebAssembly.Instance(m, {
8   host: {
9     two_i32: () => [100, 101],
10     two_i64: () => [102n, 103n],
11     two_f32: () => [104, 105],
12     two_f64: () => [106, 107],
13     mishmash: () => [108, 109, 110, 111n, 112, 113],
14   }
15 });
16
17 assert.deepEqual(i.exports.return_two_i32(), [1, 2])
18 assert.deepEqual(i.exports.return_two_i64(), [3, 4])
19 assert.deepEqual(i.exports.return_two_f32(), [5, 6])
20 assert.deepEqual(i.exports.return_two_f64(), [7, 8])
21 assert.deepEqual(i.exports.return_mishmash(), [9, 10, 11, 12, 13, 14])
22 i.exports.call_imports();