diff options
author | cjihrig <cjihrig@gmail.com> | 2019-12-15 05:05:27 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-12-17 08:55:06 +0300 |
commit | 0a2355ff5f38d424d435ec145ce497a938cc9c8b (patch) | |
tree | ee9c7c5032358137ebd06e973e180addc23f1872 /test | |
parent | bd91d6dacdbea88f340008f2a4f1b36a0a1ccc54 (diff) |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/wasi/test-wasi-start-validation.js | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/test/wasi/test-wasi-start-validation.js b/test/wasi/test-wasi-start-validation.js index 3f530a42f79..8c8c6f7e44a 100644 --- a/test/wasi/test-wasi-start-validation.js +++ b/test/wasi/test-wasi-start-validation.js @@ -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); |