blob: 01df6ad4531e4ae0cfb49e887cb279289db4c302 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
console.error('run in a new empty context');
var context = vm.createContext();
var result = vm.runInContext('"passed";', context);
assert.equal('passed', result);
console.error('create a new pre-populated context');
context = vm.createContext({'foo': 'bar', 'thing': 'lala'});
assert.equal('bar', context.foo);
assert.equal('lala', context.thing);
console.error('test updating context');
result = vm.runInContext('var foo = 3;', context);
assert.equal(3, context.foo);
assert.equal('lala', context.thing);
|