-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-wasi-uint32-int32.js
More file actions
42 lines (35 loc) · 1.17 KB
/
test-wasi-uint32-int32.js
File metadata and controls
42 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { WASI } = require('wasi');
const wasm = fs.readFileSync(
path.join(__dirname, '..', 'fixtures', 'wasi-uint32-int32.wasm'),
);
const kWasiUint32Expectations = [
['test_clock_time_get', 61],
['test_clock_time_get_zero', 0],
['test_clock_time_get_one', 0],
['test_clock_time_get_int32_max', 61],
['test_clock_time_get_uint32_min', 61],
['test_clock_time_get_uint32_max', 61],
];
const kWasiUint32ExportNames = kWasiUint32Expectations.map(([name]) => name);
(async () => {
const wasi = new WASI({ version: 'preview1', returnOnExit: true });
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
const { instance } = await WebAssembly.instantiate(wasm, importObject);
assert.deepStrictEqual(
Object.keys(instance.exports).sort(),
['_start', 'memory', ...kWasiUint32ExportNames].sort(),
);
wasi.start(instance);
for (const [name, expectedErrno] of kWasiUint32Expectations) {
assert.strictEqual(
instance.exports[name](),
expectedErrno,
name,
);
}
})().then(common.mustCall());