Skip to content

Commit 48e7009

Browse files
committed
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
1 parent 29ba2eb commit 48e7009

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)