diff options
author | cjihrig <cjihrig@gmail.com> | 2019-12-14 21:05:27 -0500 |
---|---|---|
committer | Beth Griggs <Bethany.Griggs@uk.ibm.com> | 2020-02-06 02:49:30 +0000 |
commit | ceca54940ba6034ae55036fcb3a14d439d4b0afb (patch) | |
tree | f250328c634566c21919a1e19537858fa4e90bc1 | |
parent | be3fd2e7147f40877274ce1c9dab7233606618ff (diff) | |
download | node-new-ceca54940ba6034ae55036fcb3a14d439d4b0afb.tar.gz |
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>
-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 3f530a42f7..8c8c6f7e44 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); |