mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
601 B
20 lines
601 B
13 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
|
||
12 years ago
|
var vm = require('vm');
|
||
13 years ago
|
|
||
12 years ago
|
console.error('run in a new empty context');
|
||
|
var context = vm.createContext();
|
||
|
var result = vm.runInContext('"passed";', context);
|
||
13 years ago
|
assert.equal('passed', result);
|
||
|
|
||
12 years ago
|
console.error('create a new pre-populated context');
|
||
|
context = vm.createContext({'foo': 'bar', 'thing': 'lala'});
|
||
13 years ago
|
assert.equal('bar', context.foo);
|
||
|
assert.equal('lala', context.thing);
|
||
|
|
||
12 years ago
|
console.error('test updating context');
|
||
|
result = vm.runInContext('var foo = 3;', context);
|
||
13 years ago
|
assert.equal(3, context.foo);
|
||
|
assert.equal('lala', context.thing);
|