File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -72,21 +72,21 @@ global.gc();
72
72
fn ( ) ;
73
73
// Should not crash
74
74
75
- {
76
- // Verify that providing a custom filename as a string argument works.
75
+ const filename = 'test_file.vm' ;
76
+ for ( const arg of [ filename , { filename } ] ) {
77
+ // Verify that providing a custom filename works.
77
78
const code = 'throw new Error("foo");' ;
78
- const file = 'test_file.vm' ;
79
79
80
80
assert . throws ( ( ) => {
81
- vm . runInNewContext ( code , { } , file ) ;
81
+ vm . runInNewContext ( code , { } , arg ) ;
82
82
} , ( err ) => {
83
83
const lines = err . stack . split ( '\n' ) ;
84
84
85
- assert . strictEqual ( lines [ 0 ] . trim ( ) , `${ file } :1` ) ;
85
+ assert . strictEqual ( lines [ 0 ] . trim ( ) , `${ filename } :1` ) ;
86
86
assert . strictEqual ( lines [ 1 ] . trim ( ) , code ) ;
87
87
// Skip lines[2] and lines[3]. They're just a ^ and blank line.
88
88
assert . strictEqual ( lines [ 4 ] . trim ( ) , 'Error: foo' ) ;
89
- assert . strictEqual ( lines [ 5 ] . trim ( ) , `at ${ file } :1:7` ) ;
89
+ assert . strictEqual ( lines [ 5 ] . trim ( ) , `at ${ filename } :1:7` ) ;
90
90
// The rest of the stack is uninteresting.
91
91
return true ;
92
92
} ) ;
You can’t perform that action at this time.
0 commit comments