Skip to content

Commit

Permalink
doc: replace const / var with let
Browse files Browse the repository at this point in the history
PR-URL: #30446
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
duncanhealy authored and BridgeAR committed Nov 19, 2019
1 parent 5869f2b commit c40e242
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/parallel/test-vm-function-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,22 @@ const o = vm.createContext({ console });

// Function declaration and expression should both be copied to the
// sandboxed context.
let code = 'var a = function() {};\n';
let code = 'let a = function() {};\n';
code += 'function b(){}\n';
code += 'var c = function() {};\n';
code += 'var d = () => {};\n';
code += 'let e = () => {};\n';

// Grab the global b function as the completion value, to ensure that
// we are getting the global function, and not some other thing
code += '(function(){return this})().b;\n';

const res = vm.runInContext(code, o, 'test');

assert.strictEqual(typeof res, 'function');
assert.strictEqual(res.name, 'b');
assert.strictEqual(typeof o.a, 'function');
assert.strictEqual(typeof o.a, 'undefined');
assert.strictEqual(typeof o.b, 'function');
assert.strictEqual(typeof o.c, 'function');
assert.strictEqual(typeof o.d, 'function');
assert.strictEqual(typeof o.e, 'undefined');
assert.strictEqual(res, o.b);

0 comments on commit c40e242

Please sign in to comment.