0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-vm-syntax-error-message.js
James M Snell 4b23b42981 test: improve multiple vm tests
PR-URL: https://github.com/nodejs/node/pull/14458
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2017-08-03 11:00:23 -07:00

23 lines
603 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const child_process = require('child_process');
const p = child_process.spawn(process.execPath, [
'-e',
'vm = require("vm");' +
'context = vm.createContext({});' +
'try { vm.runInContext("throw new Error(\'boo\')", context); } ' +
'catch (e) { console.log(e.message); }'
]);
p.stderr.on('data', common.mustNotCall());
let output = '';
p.stdout.on('data', (data) => output += data);
p.stdout.on('end', common.mustCall(() => {
assert.strictEqual(output.replace(/[\r\n]+/g, ''), 'boo');
}));