Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: test-vm-function-declaration test add let declaration of function
  • Loading branch information
duncanhealy committed Nov 12, 2019
commit c248f68288894f152e7e6dc74a8a66375c4986bc
6 changes: 4 additions & 2 deletions test/parallel/test-vm-function-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ 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';
Comment thread
addaleax marked this conversation as resolved.
code += 'function b(){}\n';
code += 'var c = function() {};\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');
Comment thread
BridgeAR marked this conversation as resolved.
Outdated
assert.strictEqual(typeof o.b, 'function');
assert.strictEqual(typeof o.c, 'function');

assert.strictEqual(res, o.b);