From 3e32397c26311b62485ce6da871a08f2906f4235 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 2 Mar 2016 12:41:46 -0500 Subject: [PATCH] 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 Reviewed-By: Wyatt Preul Reviewed-By: Rich Trott --- test/known_issues/test-vm-function-redefinition.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/known_issues/test-vm-function-redefinition.js diff --git a/test/known_issues/test-vm-function-redefinition.js b/test/known_issues/test-vm-function-redefinition.js new file mode 100644 index 00000000000000..fa1ddde389244e --- /dev/null +++ b/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);