Skip to content

Commit 325dc23

Browse files
duncanhealytargos
authored andcommitted
doc: replace const / var with let
PR-URL: #30446 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 58016e0 commit 325dc23

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎test/parallel/test-vm-function-declaration.js‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,22 @@ const o = vm.createContext({ console });
2828

2929
// Function declaration and expression should both be copied to the
3030
// sandboxed context.
31-
letcode='var a = function() {};\n';
31+
letcode='let a = function() {};\n';
3232
code+='function b(){}\n';
33+
code+='var c = function() {};\n';
34+
code+='var d = () => {};\n';
35+
code+='let e = () => {};\n';
3336

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

3841
constres=vm.runInContext(code,o,'test');
39-
4042
assert.strictEqual(typeofres,'function');
4143
assert.strictEqual(res.name,'b');
42-
assert.strictEqual(typeofo.a,'function');
44+
assert.strictEqual(typeofo.a,'undefined');
4345
assert.strictEqual(typeofo.b,'function');
46+
assert.strictEqual(typeofo.c,'function');
47+
assert.strictEqual(typeofo.d,'function');
48+
assert.strictEqual(typeofo.e,'undefined');
4449
assert.strictEqual(res,o.b);

0 commit comments

Comments
 (0)