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
Backport-URL: https://github.com/nodejs/node/pull/5785
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>
v4.x
cjihrig 9 years ago
committed by Myles Borins
parent
commit
9952bcf203
  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