test: simplify test-wasi-start-validation.js

This commit removes an extra block scope, and avoid reading
the simple.wasm file for every test case.

PR-URL: https://github.com/nodejs/node/pull/30972
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig authored and Beth Griggs committed 2020-02-06 02:49:30 +00:00
1 parent be3fd2e714
commit ceca54940b
1 file changed
+9 -14
+9 -14
View File
@@ -6,6 +6,7 @@ const assert = require('assert');
const { WASI } = require('wasi');
const fixtures = require('../common/fixtures');
const bufferSource = fixtures.readSync('simple.wasm');
{
const wasi = new WASI();
@@ -17,23 +18,19 @@ const fixtures = require('../common/fixtures');
);
}
{
(async () => {
const wasi = new WASI({});
(async () => {
const bufferSource = fixtures.readSync('simple.wasm');
const wasm = await WebAssembly.compile(bufferSource);
const instance = await WebAssembly.instantiate(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/ }
);
})();
}
assert.throws(
() => { wasi.start(instance); },
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Memory\b/ }
);
})();
(async () => {
const wasi = new WASI();
const bufferSource = fixtures.readSync('simple.wasm');
const wasm = await WebAssembly.compile(bufferSource);
const instance = await WebAssembly.instantiate(wasm);
const values = [undefined, null, 'foo', 42, true, false, () => {}];
@@ -54,7 +51,6 @@ const fixtures = require('../common/fixtures');
(async () => {
const wasi = new WASI();
const bufferSource = fixtures.readSync('simple.wasm');
const wasm = await WebAssembly.compile(bufferSource);
const instance = await WebAssembly.instantiate(wasm);
@@ -79,7 +75,6 @@ const fixtures = require('../common/fixtures');
(async () => {
const wasi = new WASI();
const bufferSource = fixtures.readSync('simple.wasm');
const wasm = await WebAssembly.compile(bufferSource);
const instance = await WebAssembly.instantiate(wasm);