Skip to content

Commit

Permalink
test: add test for validation for wasi.start() argument
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
Trott authored and MylesBorins committed Dec 17, 2019
1 parent d456aa0 commit 60485dc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/wasi/test-wasi-start-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'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/ }
);
})();
}

0 comments on commit 60485dc

Please sign in to comment.