Skip to content

Commit 7139325

Browse files
Trotttargos
authored andcommitted
test: add test for validation for wasi.start() argument
PR-URL: #30919 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent ace3e70 commit 7139325

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const { WASI } = require('wasi');
6+
7+
const fixtures = require('../common/fixtures');
8+
9+
{
10+
const wasi = new WASI();
11+
assert.throws(
12+
() => {
13+
wasi.start();
14+
},
15+
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Instance\b/ }
16+
);
17+
}
18+
19+
{
20+
const wasi = new WASI({});
21+
(async () => {
22+
const bufferSource = fixtures.readSync('simple.wasm');
23+
const wasm = await WebAssembly.compile(bufferSource);
24+
const instance = await WebAssembly.instantiate(wasm);
25+
26+
assert.throws(
27+
() => { wasi.start(instance); },
28+
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Memory\b/ }
29+
);
30+
})();
31+
}

0 commit comments

Comments
 (0)