mirror of https://github.com/nodejs/node.git
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>pull/5528/merge
parent
32e1f9d0b5
commit
e38e2a6012
|
@ -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…
Reference in New Issue