@@ -5,34 +5,34 @@ const assert = require('assert');
5
5
const { WASI } = require ( 'wasi' ) ;
6
6
7
7
// If args is undefined, it should default to [] and should not throw.
8
- new WASI ( { } ) ;
8
+ new WASI ( { version : 'preview1' } ) ;
9
9
10
10
// If args is not an Array and not undefined, it should throw.
11
- assert . throws ( ( ) => { new WASI ( { args : 'fhqwhgads' } ) ; } ,
11
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , args : 'fhqwhgads' } ) ; } ,
12
12
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b a r g s \b / } ) ;
13
13
14
14
// If env is not an Object and not undefined, it should throw.
15
- assert . throws ( ( ) => { new WASI ( { env : 'fhqwhgads' } ) ; } ,
15
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , env : 'fhqwhgads' } ) ; } ,
16
16
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b e n v \b / } ) ;
17
17
18
18
// If preopens is not an Object and not undefined, it should throw.
19
- assert . throws ( ( ) => { new WASI ( { preopens : 'fhqwhgads' } ) ; } ,
19
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , preopens : 'fhqwhgads' } ) ; } ,
20
20
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b p r e o p e n s \b / } ) ;
21
21
22
22
// If returnOnExit is not a boolean and not undefined, it should throw.
23
- assert . throws ( ( ) => { new WASI ( { returnOnExit : 'fhqwhgads' } ) ; } ,
23
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , returnOnExit : 'fhqwhgads' } ) ; } ,
24
24
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b r e t u r n O n E x i t \b / } ) ;
25
25
26
26
// If stdin is not an int32 and not undefined, it should throw.
27
- assert . throws ( ( ) => { new WASI ( { stdin : 'fhqwhgads' } ) ; } ,
27
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , stdin : 'fhqwhgads' } ) ; } ,
28
28
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b s t d i n \b / } ) ;
29
29
30
30
// If stdout is not an int32 and not undefined, it should throw.
31
- assert . throws ( ( ) => { new WASI ( { stdout : 'fhqwhgads' } ) ; } ,
31
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , stdout : 'fhqwhgads' } ) ; } ,
32
32
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b s t d o u t \b / } ) ;
33
33
34
34
// If stderr is not an int32 and not undefined, it should throw.
35
- assert . throws ( ( ) => { new WASI ( { stderr : 'fhqwhgads' } ) ; } ,
35
+ assert . throws ( ( ) => { new WASI ( { version : 'preview1' , stderr : 'fhqwhgads' } ) ; } ,
36
36
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b s t d e r r \b / } ) ;
37
37
38
38
// If options is provided, but not an object, the constructor should throw.
@@ -43,13 +43,16 @@ assert.throws(() => { new WASI({ stderr: 'fhqwhgads' }); },
43
43
44
44
// Verify that exceptions thrown from the binding layer are handled.
45
45
assert . throws ( ( ) => {
46
- new WASI ( { preopens : { '/sandbox' : '__/not/real/path' } } ) ;
46
+ new WASI ( { version : 'preview1' , preopens : { '/sandbox' : '__/not/real/path' } } ) ;
47
47
} , { code : 'UVWASI_ENOENT' , message : / u v w a s i _ i n i t / } ) ;
48
48
49
49
// If version is not a string, it should throw
50
50
assert . throws ( ( ) => { new WASI ( { version : { x : 'y' } } ) ; } ,
51
51
{ code : 'ERR_INVALID_ARG_TYPE' , message : / \b v e r s i o n \b / } ) ;
52
52
53
+ // If version is not specified, it should throw.
54
+ assert . throws ( ( ) => { new WASI ( ) ; } ,
55
+ { code : 'ERR_INVALID_ARG_TYPE' , message : / \b v e r s i o n \b / } ) ;
53
56
54
57
// If version is an unsupported version, it should throw
55
58
assert . throws ( ( ) => { new WASI ( { version : 'not_a_version' } ) ; } ,
0 commit comments