Skip to content

Commit

Permalink
test: improve wasi test coverage
Browse files Browse the repository at this point in the history
Add test coverage for options validation in WASI constructor.

PR-URL: #30770
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
Trott authored and targos committed Dec 9, 2019
1 parent fb31ab5 commit 30756e3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/wasi/test-wasi-options-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

// Flags: --experimental-wasi-unstable-preview0

require('../common');
const assert = require('assert');
const { WASI } = require('wasi');

// If args is undefined, it should default to [] and should not throw.
new WASI({});

// If args is not an Array and not undefined, it should throw.
assert.throws(() => { new WASI({ args: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE' });

// If env is not an Object and not undefined, it should throw.
assert.throws(() => { new WASI({ env: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE' });

// If preopens is not an Object and not undefined, it should throw.
assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE' });

0 comments on commit 30756e3

Please sign in to comment.