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
  • Loading branch information
cjihrig committed Mar 3, 2016
1 parent 29ba2eb commit 48e7009
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 48e7009

Please sign in to comment.