@@ -6,29 +6,29 @@ const vm = require('vm');
6
6
const Script = vm . Script ;
7
7
let script = new Script ( '"passed";' ) ;
8
8
9
- console . error ( 'run in a new empty context' ) ;
9
+ // Run in a new empty context
10
10
let context = vm . createContext ( ) ;
11
11
let result = script . runInContext ( context ) ;
12
12
assert . strictEqual ( 'passed' , result ) ;
13
13
14
- console . error ( 'create a new pre-populated context' ) ;
15
- context = vm . createContext ( { 'foo' : 'bar' , 'thing' : 'lala' } ) ;
14
+ // Create a new pre-populated context
15
+ context = vm . createContext ( { 'foo' : 'bar' , 'thing' : 'lala' } ) ;
16
16
assert . strictEqual ( 'bar' , context . foo ) ;
17
17
assert . strictEqual ( 'lala' , context . thing ) ;
18
18
19
- console . error ( 'test updating context' ) ;
19
+ // Test updating context
20
20
script = new Script ( 'foo = 3;' ) ;
21
21
result = script . runInContext ( context ) ;
22
22
assert . strictEqual ( 3 , context . foo ) ;
23
23
assert . strictEqual ( 'lala' , context . thing ) ;
24
24
25
25
// Issue GH-227:
26
- assert . throws ( function ( ) {
26
+ assert . throws ( ( ) => {
27
27
vm . runInNewContext ( '' , null , 'some.js' ) ;
28
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 $ / ) ;
29
29
30
30
// Issue GH-1140:
31
- console . error ( 'test runInContext signature' ) ;
31
+ // Test runInContext signature
32
32
let gh1140Exception ;
33
33
try {
34
34
vm . runInContext ( 'throw new Error()' , context , 'expected-filename.js' ) ;
@@ -56,8 +56,8 @@ const contextifiedSandboxErrorMsg =
56
56
} ) ;
57
57
58
58
// Issue GH-693:
59
- console . error ( 'test RegExp as argument to assert.throws' ) ;
60
- script = vm . createScript ( 'var assert = require(\'assert\'); assert.throws(' +
59
+ // Test RegExp as argument to assert.throws
60
+ script = vm . createScript ( 'const assert = require(\'assert\'); assert.throws(' +
61
61
'function() { throw "hello world"; }, /hello/);' ,
62
62
'some.js' ) ;
63
63
script . runInNewContext ( { require : require } ) ;
@@ -71,14 +71,14 @@ assert.strictEqual(script.runInContext(ctx), false);
71
71
72
72
// Error on the first line of a module should
73
73
// have the correct line and column number
74
- assert . throws ( function ( ) {
74
+ assert . throws ( ( ) => {
75
75
vm . runInContext ( 'throw new Error()' , context , {
76
76
filename : 'expected-filename.js' ,
77
77
lineOffset : 32 ,
78
78
columnOffset : 123
79
79
} ) ;
80
- } , function ( err ) {
81
- return / e x p e c t e d - f i l e n a m e .j s : 3 3 : 1 3 0 / . test ( err . stack ) ;
80
+ } , ( err ) => {
81
+ return / e x p e c t e d - f i l e n a m e \ .j s : 3 3 : 1 3 0 / . test ( err . stack ) ;
82
82
} , 'Expected appearance of proper offset in Error stack' ) ;
83
83
84
84
// https://github.com/nodejs/node/issues/6158
0 commit comments