xref: /third_party/node/test/parallel/test-vm-syntax-error-message.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst child_process = require('child_process');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst p = child_process.spawn(process.execPath, [
71cb0ef41Sopenharmony_ci  '-e',
81cb0ef41Sopenharmony_ci  'vm = require("vm");' +
91cb0ef41Sopenharmony_ci      'context = vm.createContext({});' +
101cb0ef41Sopenharmony_ci      'try { vm.runInContext("throw new Error(\'boo\')", context); } ' +
111cb0ef41Sopenharmony_ci      'catch (e) { console.log(e.message); }',
121cb0ef41Sopenharmony_ci]);
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cip.stderr.on('data', common.mustNotCall());
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cilet output = '';
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cip.stdout.on('data', (data) => output += data);
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cip.stdout.on('end', common.mustCall(() => {
211cb0ef41Sopenharmony_ci  assert.strictEqual(output.replace(/[\r\n]+/g, ''), 'boo');
221cb0ef41Sopenharmony_ci}));
23

Indexes created Thu Nov 07 10:32:03 CST 2024