Skip to content

Commit 29e26b3

Browse files
cjihrigFishrock123
authored andcommitted
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: #548 PR-URL: #5528 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Wyatt Preul <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 5aa17dc commit 29e26b3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/548
3+
require('../common');
4+
const assert = require('assert');
5+
const vm = require('vm');
6+
const context = vm.createContext();
7+
8+
vm.runInContext('function test() { return 0; }', context);
9+
vm.runInContext('function test() { return 1; }', context);
10+
const result = vm.runInContext('test()', context);
11+
assert.strictEqual(result, 1);

0 commit comments

Comments
 (0)