mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 13:09:42 +00:00

Correct alignment on variable assignments that span multiple lines in preparation for lint rule to enforce such alignment. PR-URL: https://github.com/nodejs/node/pull/6242 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com>
39 lines
1016 B
JavaScript
39 lines
1016 B
JavaScript
/* eslint-disable strict */
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var vm = require('vm');
|
|
|
|
common.globalCheck = false;
|
|
|
|
console.error('run a string');
|
|
var result = vm.runInThisContext('\'passed\';');
|
|
assert.equal('passed', result);
|
|
|
|
console.error('thrown error');
|
|
assert.throws(function() {
|
|
vm.runInThisContext('throw new Error(\'test\');');
|
|
}, /test/);
|
|
|
|
global.hello = 5;
|
|
vm.runInThisContext('hello = 2');
|
|
assert.equal(2, global.hello);
|
|
|
|
|
|
console.error('pass values');
|
|
var code = 'foo = 1;' +
|
|
'bar = 2;' +
|
|
'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');';
|
|
global.foo = 2;
|
|
global.obj = { foo: 0, baz: 3 };
|
|
/* eslint-disable no-unused-vars */
|
|
var baz = vm.runInThisContext(code);
|
|
/* eslint-enable no-unused-vars */
|
|
assert.equal(0, global.obj.foo);
|
|
assert.equal(2, global.bar);
|
|
assert.equal(1, global.foo);
|
|
|
|
console.error('call a function');
|
|
global.f = function() { global.foo = 100; };
|
|
vm.runInThisContext('f()');
|
|
assert.equal(100, global.foo);
|