@@ -35,10 +35,10 @@ try {
35
35
} catch ( e ) {
36
36
gh1140Exception = e ;
37
37
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 } ` ) ;
39
39
}
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 ') ;
42
42
43
43
// GH-558, non-context argument segfaults / raises assertion
44
44
const nonContextualSandboxErrorMsg =
@@ -69,18 +69,22 @@ Object.defineProperty(ctx, 'b', { configurable: false });
69
69
ctx = vm . createContext ( ctx ) ;
70
70
assert . strictEqual ( script . runInContext ( ctx ) , false ) ;
71
71
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
+ }
84
88
85
89
// https://github.com/nodejs/node/issues/6158
86
90
ctx = new Proxy ( { } , { } ) ;
0 commit comments