Skip to content

Commit

Permalink
test: bug repro for vm function redefinition
Browse files Browse the repository at this point in the history
This commit adds a failing test case for the vm module.
Currently, if runInContext() defines a function, and a later call
to runInContext() redefines the same function, the original
function is not overwritten.

Refs: #548
PR-URL: #5528
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Wyatt Preul <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
cjihrig authored and Fishrock123 committed Mar 8, 2016
1 parent 5aa17dc commit 29e26b3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/known_issues/test-vm-function-redefinition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';
// Refs: https://github.com/nodejs/node/issues/548
require('../common');
const assert = require('assert');
const vm = require('vm');
const context = vm.createContext();

vm.runInContext('function test() { return 0; }', context);
vm.runInContext('function test() { return 1; }', context);
const result = vm.runInContext('test()', context);
assert.strictEqual(result, 1);

0 comments on commit 29e26b3

Please sign in to comment.