diff options
Diffstat (limited to 'test/parallel/test-repl-uncaught-exception-standalone.js')
-rw-r--r-- | test/parallel/test-repl-uncaught-exception-standalone.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/parallel/test-repl-uncaught-exception-standalone.js b/test/parallel/test-repl-uncaught-exception-standalone.js new file mode 100644 index 0000000000..ae7b214fef --- /dev/null +++ b/test/parallel/test-repl-uncaught-exception-standalone.js @@ -0,0 +1,38 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); +const child = cp.spawn(process.execPath, ['-i']); +let output = ''; + +child.stdout.setEncoding('utf8'); +child.stdout.on('data', (data) => { + output += data; +}); + +child.on('exit', common.mustCall(() => { + const results = output.split('\n'); + results.shift(); + assert.deepStrictEqual( + results, + [ + 'Type ".help" for more information.', + // x\n + '> Thrown:', + 'ReferenceError: x is not defined', + // Added `uncaughtException` listener. + '> short', + 'undefined', + // x\n + '> Foobar', + '> ' + ] + ); +})); + +child.stdin.write('x\n'); +child.stdin.write( + 'process.on("uncaughtException", () => console.log("Foobar"));' + + 'console.log("short")\n'); +child.stdin.write('x\n'); +child.stdin.end(); |