File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -72,21 +72,21 @@ global.gc();
7272fn ( ) ;
7373// Should not crash
7474
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.
7778 const code = 'throw new Error("foo");' ;
78- const file = 'test_file.vm' ;
7979
8080 assert . throws ( ( ) => {
81- vm . runInNewContext ( code , { } , file ) ;
81+ vm . runInNewContext ( code , { } , arg ) ;
8282 } , ( err ) => {
8383 const lines = err . stack . split ( '\n' ) ;
8484
85- assert . strictEqual ( lines [ 0 ] . trim ( ) , `${ file } :1` ) ;
85+ assert . strictEqual ( lines [ 0 ] . trim ( ) , `${ filename } :1` ) ;
8686 assert . strictEqual ( lines [ 1 ] . trim ( ) , code ) ;
8787 // Skip lines[2] and lines[3]. They're just a ^ and blank line.
8888 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` ) ;
9090 // The rest of the stack is uninteresting.
9191 return true ;
9292 } ) ;
You can’t perform that action at this time.
0 commit comments