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: nodejs#548
PR-URL: nodejs#5528
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
cjihrig committed Mar 18, 2016
1 parent 4b04cb4 commit bab9aaf
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 bab9aaf

Please sign in to comment.