Skip to content

Commit 5e268b8

Browse files
cjihrigMylesBorins
authored andcommitted
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: #30972 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c2d9552 commit 5e268b8

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

test/wasi/test-wasi-start-validation.js

+9-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const assert = require('assert');
66
const { WASI } = require('wasi');
77

88
const fixtures = require('../common/fixtures');
9+
const bufferSource = fixtures.readSync('simple.wasm');
910

1011
{
1112
const wasi = new WASI();
@@ -17,23 +18,19 @@ const fixtures = require('../common/fixtures');
1718
);
1819
}
1920

20-
{
21+
(async () => {
2122
const wasi = new WASI({});
22-
(async () => {
23-
const bufferSource = fixtures.readSync('simple.wasm');
24-
const wasm = await WebAssembly.compile(bufferSource);
25-
const instance = await WebAssembly.instantiate(wasm);
23+
const wasm = await WebAssembly.compile(bufferSource);
24+
const instance = await WebAssembly.instantiate(wasm);
2625

27-
assert.throws(
28-
() => { wasi.start(instance); },
29-
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Memory\b/ }
30-
);
31-
})();
32-
}
26+
assert.throws(
27+
() => { wasi.start(instance); },
28+
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Memory\b/ }
29+
);
30+
})();
3331

3432
(async () => {
3533
const wasi = new WASI();
36-
const bufferSource = fixtures.readSync('simple.wasm');
3734
const wasm = await WebAssembly.compile(bufferSource);
3835
const instance = await WebAssembly.instantiate(wasm);
3936
const values = [undefined, null, 'foo', 42, true, false, () => {}];
@@ -54,7 +51,6 @@ const fixtures = require('../common/fixtures');
5451

5552
(async () => {
5653
const wasi = new WASI();
57-
const bufferSource = fixtures.readSync('simple.wasm');
5854
const wasm = await WebAssembly.compile(bufferSource);
5955
const instance = await WebAssembly.instantiate(wasm);
6056

@@ -79,7 +75,6 @@ const fixtures = require('../common/fixtures');
7975

8076
(async () => {
8177
const wasi = new WASI();
82-
const bufferSource = fixtures.readSync('simple.wasm');
8378
const wasm = await WebAssembly.compile(bufferSource);
8479
const instance = await WebAssembly.instantiate(wasm);
8580

0 commit comments

Comments
 (0)