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
Prev Previous commit
test: add function declaration tests for fat arrow
  • Loading branch information
duncanhealy committed Nov 12, 2019
commit b05c0e694eab23a8b1e7af94aac667c26347a3bd
7 changes: 5 additions & 2 deletions test/parallel/test-vm-function-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const o = vm.createContext({ console });
let code = 'let a = function() {};\n';
Comment thread
addaleax marked this conversation as resolved.
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
Expand All @@ -39,8 +41,9 @@ 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);