11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst cp = require('child_process');
51cb0ef41Sopenharmony_ciconst child = cp.spawn(process.execPath, ['-i']);
61cb0ef41Sopenharmony_cilet output = '';
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cichild.stdout.setEncoding('utf8');
91cb0ef41Sopenharmony_cichild.stdout.on('data', (data) => {
101cb0ef41Sopenharmony_ci  output += data;
111cb0ef41Sopenharmony_ci});
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cichild.on('exit', common.mustCall(() => {
141cb0ef41Sopenharmony_ci  const results = output.split('\n');
151cb0ef41Sopenharmony_ci  results.shift();
161cb0ef41Sopenharmony_ci  assert.deepStrictEqual(
171cb0ef41Sopenharmony_ci    results,
181cb0ef41Sopenharmony_ci    [
191cb0ef41Sopenharmony_ci      'Type ".help" for more information.',
201cb0ef41Sopenharmony_ci      // x\n
211cb0ef41Sopenharmony_ci      '> Uncaught ReferenceError: x is not defined',
221cb0ef41Sopenharmony_ci      // Added `uncaughtException` listener.
231cb0ef41Sopenharmony_ci      '> short',
241cb0ef41Sopenharmony_ci      'undefined',
251cb0ef41Sopenharmony_ci      // x\n
261cb0ef41Sopenharmony_ci      '> Foobar',
271cb0ef41Sopenharmony_ci      '> ',
281cb0ef41Sopenharmony_ci    ]
291cb0ef41Sopenharmony_ci  );
301cb0ef41Sopenharmony_ci}));
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_cichild.stdin.write('x\n');
331cb0ef41Sopenharmony_cichild.stdin.write(
341cb0ef41Sopenharmony_ci  'process.on("uncaughtException", () => console.log("Foobar"));' +
351cb0ef41Sopenharmony_ci  'console.log("short")\n');
361cb0ef41Sopenharmony_cichild.stdin.write('x\n');
371cb0ef41Sopenharmony_cichild.stdin.end();
38