From 2e70ad391b1df2503e4359f865dc5b86b286ba13 Mon Sep 17 00:00:00 2001 From: Duncan Healy Date: Tue, 12 Nov 2019 16:54:35 +0000 Subject: [PATCH] doc: replace const / var with let PR-URL: https://github.com/nodejs/node/pull/30446 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil Reviewed-By: Ruben Bridgewater --- test/parallel/test-vm-function-declaration.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-vm-function-declaration.js b/test/parallel/test-vm-function-declaration.js index 6405babfa78148..766e5ec78b10ea 100644 --- a/test/parallel/test-vm-function-declaration.js +++ b/test/parallel/test-vm-function-declaration.js @@ -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);