Skip to content
Prev Previous commit
Next Next commit
test: test-vm-create-and-run-in-context
  • Loading branch information
jasnell committed Aug 1, 2017
commit 684c01ff2c278db5a71f87b14f7cac14c90766d8
8 changes: 4 additions & 4 deletions test/parallel/test-vm-create-and-run-in-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ const assert = require('assert');

const vm = require('vm');

console.error('run in a new empty context');
// Run in a new empty context
let context = vm.createContext();
let result = vm.runInContext('"passed";', context);
assert.strictEqual('passed', result);

console.error('create a new pre-populated context');
// Create a new pre-populated context
context = vm.createContext({ 'foo': 'bar', 'thing': 'lala' });
assert.strictEqual('bar', context.foo);
assert.strictEqual('lala', context.thing);

console.error('test updating context');
// Test updating context
result = vm.runInContext('var foo = 3;', context);
assert.strictEqual(3, context.foo);
assert.strictEqual('lala', context.thing);

// https://github.com/nodejs/node/issues/5768
console.error('run in contextified sandbox without referencing the context');
// Run in contextified sandbox without referencing the context
const sandbox = { x: 1 };
vm.createContext(sandbox);
global.gc();
Expand Down