1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const cp = require('child_process'); 5const child = cp.spawn(process.execPath, ['-i']); 6let output = ''; 7 8child.stdout.setEncoding('utf8'); 9child.stdout.on('data', (data) => { 10 output += data; 11}); 12 13child.on('exit', common.mustCall(() => { 14 const results = output.split('\n'); 15 results.shift(); 16 assert.deepStrictEqual( 17 results, 18 [ 19 'Type ".help" for more information.', 20 // x\n 21 '> Uncaught ReferenceError: x is not defined', 22 // Added `uncaughtException` listener. 23 '> short', 24 'undefined', 25 // x\n 26 '> Foobar', 27 '> ', 28 ] 29 ); 30})); 31 32child.stdin.write('x\n'); 33child.stdin.write( 34 'process.on("uncaughtException", () => console.log("Foobar"));' + 35 'console.log("short")\n'); 36child.stdin.write('x\n'); 37child.stdin.end(); 38