Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: use shorthand properties in vm tests
  • Loading branch information
tniessen committed Jan 11, 2018
commit a4eaf4566c934da81e6fca4b2ea1a07bd23d0e83
2 changes: 1 addition & 1 deletion test/parallel/test-vm-access-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const assert = require('assert');
const vm = require('vm');

assert.doesNotThrow(function() {
const context = vm.createContext({ process: process });
const context = vm.createContext({ process });
const result = vm.runInContext('process.env["PATH"]', context);
assert.notStrictEqual(undefined, result);
});
2 changes: 1 addition & 1 deletion test/parallel/test-vm-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const contextifiedSandboxErrorMsg =
script = vm.createScript('const assert = require(\'assert\'); assert.throws(' +
'function() { throw "hello world"; }, /hello/);',
'some.js');
script.runInNewContext({ require: require });
script.runInNewContext({ require });

// Issue GH-7529
script = vm.createScript('delete b');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-function-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require('../common');
const assert = require('assert');

const vm = require('vm');
const o = vm.createContext({ console: console });
const o = vm.createContext({ console });

// Function declaration and expression should both be copied to the
// sandboxed context.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-global-define-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const code =
'f;\n';

const x = {};
const o = vm.createContext({ console: console, x: x });
const o = vm.createContext({ console, x });

const res = vm.runInContext(code, o, 'test');

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-harmony-symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ assert.strictEqual(typeof sandbox.Symbol, 'function');
assert.notStrictEqual(sandbox.Symbol, Symbol);

// Unless we copy the Symbol constructor explicitly, of course.
sandbox = { Symbol: Symbol };
sandbox = { Symbol };
vm.runInNewContext('this.Symbol = Symbol', sandbox);
assert.strictEqual(typeof sandbox.Symbol, 'function');
assert.strictEqual(sandbox.Symbol, Symbol);
2 changes: 1 addition & 1 deletion test/parallel/test-vm-new-script-new-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const Script = require('vm').Script;
{
const script = new Script('f.a = 2');
const f = { a: 1 };
script.runInNewContext({ f: f });
script.runInNewContext({ f });
assert.strictEqual(f.a, 2);

assert.throws(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-vm-proxies.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assert.strictEqual(typeof sandbox.Proxy, 'function');
assert.notStrictEqual(sandbox.Proxy, Proxy);

// Unless we copy the Proxy object explicitly, of course.
sandbox = { Proxy: Proxy };
sandbox = { Proxy };
vm.runInNewContext('this.Proxy = Proxy', sandbox);
assert.strictEqual(typeof sandbox.Proxy, 'function');
assert.strictEqual(sandbox.Proxy, Proxy);
2 changes: 1 addition & 1 deletion test/parallel/test-vm-run-in-new-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ assert.strictEqual(global.foo, 100);

// Modify an object by reference
const f = { a: 1 };
vm.runInNewContext('f.a = 2', { f: f });
vm.runInNewContext('f.a = 2', { f });
assert.strictEqual(f.a, 2);

// Use function in context without referencing context
Expand Down
8 changes: 3 additions & 5 deletions test/parallel/test-vm-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ assert.throws(function() {
const context = {
log: console.log,
runInVM: function(timeout) {
vm.runInNewContext('while(true) {}', context, { timeout: timeout });
vm.runInNewContext('while(true) {}', context, { timeout });
}
};
vm.runInNewContext('runInVM(10)', context, { timeout: 10000 });
Expand All @@ -58,7 +58,7 @@ assert.throws(function() {
assert.throws(function() {
const context = {
runInVM: function(timeout) {
vm.runInNewContext('while(true) {}', context, { timeout: timeout });
vm.runInNewContext('while(true) {}', context, { timeout });
}
};
vm.runInNewContext('runInVM(10000)', context, { timeout: 100 });
Expand All @@ -69,9 +69,7 @@ assert.throws(function() {
assert.throws(function() {
const context = {
runInVM: function(timeout) {
vm.runInNewContext('throw new Error(\'foobar\')', context, {
timeout: timeout
});
vm.runInNewContext('throw new Error(\'foobar\')', context, { timeout });
}
};
vm.runInNewContext('runInVM(10000)', context, { timeout: 100000 });
Expand Down