@@ -25,7 +25,7 @@ assert.strictEqual('lala', context.thing);
2525// Issue GH-227:
2626assert . throws ( function ( ) {
2727 vm . runInNewContext ( '' , null , 'some.js' ) ;
28- } , TypeError ) ;
28+ } , / ^ 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 $ / ) ;
2929
3030// Issue GH-1140:
3131console . error ( 'test runInContext signature' ) ;
@@ -41,9 +41,18 @@ assert.ok(gh1140Exception,
4141 'expected exception from runInContext signature test' ) ;
4242
4343// GH-558, non-context argument segfaults / raises assertion
44- [ undefined , null , 0 , 0.0 , '' , { } , [ ] ] . forEach ( function ( e ) {
45- assert . throws ( function ( ) { script . runInContext ( e ) ; } , TypeError ) ;
46- assert . throws ( function ( ) { vm . runInContext ( '' , e ) ; } , TypeError ) ;
44+ const nonContextualSandboxErrorMsg =
45+ / ^ 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 \. $ / ;
46+ const contextifiedSandboxErrorMsg =
47+ / ^ 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 \. $ / ;
48+ [
49+ [ undefined , nonContextualSandboxErrorMsg ] ,
50+ [ null , nonContextualSandboxErrorMsg ] , [ 0 , nonContextualSandboxErrorMsg ] ,
51+ [ 0.0 , nonContextualSandboxErrorMsg ] , [ '' , nonContextualSandboxErrorMsg ] ,
52+ [ { } , contextifiedSandboxErrorMsg ] , [ [ ] , contextifiedSandboxErrorMsg ]
53+ ] . forEach ( ( e ) => {
54+ assert . throws ( ( ) => { script . runInContext ( e [ 0 ] ) ; } , e [ 1 ] ) ;
55+ assert . throws ( ( ) => { vm . runInContext ( '' , e [ 0 ] ) ; } , e [ 1 ] ) ;
4756} ) ;
4857
4958// Issue GH-693:
0 commit comments