Browse Source

test: bug repro for vm function redefinition

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: https://github.com/nodejs/node/issues/548
PR-URL: https://github.com/nodejs/node/pull/5528
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
v5.x
cjihrig 9 years ago
committed by Jeremiah Senkpiel
parent
commit
29e26b38c5
  1. 11
      test/known_issues/test-vm-function-redefinition.js

11
test/known_issues/test-vm-function-redefinition.js

@ -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);
Loading…
Cancel
Save