@@ -46,7 +46,7 @@ assert.strictEqual('lala', context.thing);
46
46
// Issue GH-227:
47
47
assert . throws ( function ( ) {
48
48
vm . runInNewContext ( '' , null , 'some.js' ) ;
49
- } , TypeError ) ;
49
+ } , / ^ T y p e E r r o r : s a n d b o x m u s t b e a n o b j e c t $ / ) ;
50
50
51
51
// Issue GH-1140:
52
52
console . error ( 'test runInContext signature' ) ;
@@ -62,9 +62,18 @@ assert.ok(gh1140Exception,
62
62
'expected exception from runInContext signature test' ) ;
63
63
64
64
// GH-558, non-context argument segfaults / raises assertion
65
- [ undefined , null , 0 , 0.0 , '' , { } , [ ] ] . forEach ( function ( e ) {
66
- assert . throws ( function ( ) { script . runInContext ( e ) ; } , TypeError ) ;
67
- assert . throws ( function ( ) { vm . runInContext ( '' , e ) ; } , TypeError ) ;
65
+ const nonContextualSandboxErrorMsg =
66
+ / ^ T y p e E r r o r : c o n t e x t i f i e d S a n d b o x a r g u m e n t m u s t b e a n o b j e c t \. $ / ;
67
+ const contextifiedSandboxErrorMsg =
68
+ / ^ T y p e E r r o r : s a n d b o x a r g u m e n t m u s t h a v e b e e n c o n v e r t e d t o a c o n t e x t \. $ / ;
69
+ [
70
+ [ undefined , nonContextualSandboxErrorMsg ] ,
71
+ [ null , nonContextualSandboxErrorMsg ] , [ 0 , nonContextualSandboxErrorMsg ] ,
72
+ [ 0.0 , nonContextualSandboxErrorMsg ] , [ '' , nonContextualSandboxErrorMsg ] ,
73
+ [ { } , contextifiedSandboxErrorMsg ] , [ [ ] , contextifiedSandboxErrorMsg ]
74
+ ] . forEach ( ( e ) => {
75
+ assert . throws ( ( ) => { script . runInContext ( e [ 0 ] ) ; } , e [ 1 ] ) ;
76
+ assert . throws ( ( ) => { vm . runInContext ( '' , e [ 0 ] ) ; } , e [ 1 ] ) ;
68
77
} ) ;
69
78
70
79
// Issue GH-693:
0 commit comments