@@ -35,10 +35,10 @@ try {
3535} catch ( e ) {
3636 gh1140Exception = e ;
3737 assert . ok ( / e x p e c t e d - f i l e n a m e / . test ( e . stack ) ,
38- ' expected appearance of filename in Error stack' ) ;
38+ ` expected appearance of filename in Error stack: ${ e . stack } ` ) ;
3939}
40- assert . ok ( gh1140Exception ,
41- 'expected exception from runInContext signature test ') ;
40+ // This is outside of catch block to confirm catch block ran.
41+ assert . strictEqual ( gh1140Exception . toString ( ) , 'Error ') ;
4242
4343// GH-558, non-context argument segfaults / raises assertion
4444const nonContextualSandboxErrorMsg =
@@ -69,18 +69,22 @@ Object.defineProperty(ctx, 'b', { configurable: false });
6969ctx = vm . createContext ( ctx ) ;
7070assert . strictEqual ( script . runInContext ( ctx ) , false ) ;
7171
72- // Error on the first line of a module should
73- // have the correct line and column number
74- assert . throws ( ( ) => {
75- vm . runInContext ( ' throw new Error()' , context , {
76- filename : 'expected-filename.js' ,
77- lineOffset : 32 ,
78- columnOffset : 123
79- } ) ;
80- } , ( err ) => {
81- return / ^ \^ / m. test ( err . stack ) &&
82- / e x p e c t e d - f i l e n a m e \. j s : 3 3 : 1 3 1 / . test ( err . stack ) ;
83- } , 'Expected appearance of proper offset in Error stack' ) ;
72+ // Error on the first line of a module should have the correct line and column
73+ // number.
74+ {
75+ let stack = null ;
76+ assert . throws ( ( ) => {
77+ vm . runInContext ( ' throw new Error()' , context , {
78+ filename : 'expected-filename.js' ,
79+ lineOffset : 32 ,
80+ columnOffset : 123
81+ } ) ;
82+ } , ( err ) => {
83+ stack = err . stack ;
84+ return / ^ \^ / m. test ( stack ) &&
85+ / e x p e c t e d - f i l e n a m e \. j s : 3 3 : 1 3 1 / . test ( stack ) ;
86+ } , `stack not formatted as expected: ${ stack } ` ) ;
87+ }
8488
8589// https://github.com/nodejs/node/issues/6158
8690ctx = new Proxy ( { } , { } ) ;
0 commit comments