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 committed Mar 4, 2016
1 parent 32e1f9d commit e38e2a6
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 e38e2a6

Please sign in to comment.