0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/test/wasi/test-wasi-start-validation.js
Rich Trott decc5f5506 test: add test for validation for wasi.start() argument
PR-URL: https://github.com/nodejs/node/pull/30919
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2019-12-14 16:34:54 -05:00

32 lines
697 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const { WASI } = require('wasi');
const fixtures = require('../common/fixtures');
{
const wasi = new WASI();
assert.throws(
() => {
wasi.start();
},
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Instance\b/ }
);
}
{
const wasi = new WASI({});
(async () => {
const bufferSource = fixtures.readSync('simple.wasm');
const wasm = await WebAssembly.compile(bufferSource);
const instance = await WebAssembly.instantiate(wasm);
assert.throws(
() => { wasi.start(instance); },
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Memory\b/ }
);
})();
}