diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-28 11:03:37 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-04 00:12:07 +0100 |
commit | a0778a97e19fb6e661a4277f18f758443d20470c (patch) | |
tree | f62d9ba1ec609b10aef2061e0ce1cc88536da2cb /test | |
parent | 6c38fcff1d074e058d427e817a0a61c0f03e0aba (diff) | |
download | android-node-v8-a0778a97e19fb6e661a4277f18f758443d20470c.tar.gz android-node-v8-a0778a97e19fb6e661a4277f18f758443d20470c.tar.bz2 android-node-v8-a0778a97e19fb6e661a4277f18f758443d20470c.zip |
repl: use object writer for thrown errors
This makes us use the defaults that were set for the REPL, i.e.
aligns with the printing of expression completion values, and in
particular enables color support.
PR-URL: https://github.com/nodejs/node/pull/26361
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-repl-pretty-stack.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/parallel/test-repl-pretty-stack.js b/test/parallel/test-repl-pretty-stack.js index e4137b84a4..4bf18fa1c2 100644 --- a/test/parallel/test-repl-pretty-stack.js +++ b/test/parallel/test-repl-pretty-stack.js @@ -6,7 +6,7 @@ const assert = require('assert'); const repl = require('repl'); -function run({ command, expected }) { +function run({ command, expected, ...extraREPLOptions }) { let accum = ''; const inputStream = new ArrayStream(); @@ -19,7 +19,8 @@ function run({ command, expected }) { input: inputStream, output: outputStream, terminal: false, - useColors: false + useColors: false, + ...extraREPLOptions }); r.write(`${command}\n`); @@ -45,6 +46,18 @@ const tests = [ expected: 'Thrown:\nError: Whoops!\n' }, { + command: '(() => { const err = Error(\'Whoops!\'); ' + + 'err.foo = \'bar\'; throw err; })()', + expected: 'Thrown:\n{ Error: Whoops!\n at repl:1:22 foo: \'bar\' }\n', + }, + { + command: '(() => { const err = Error(\'Whoops!\'); ' + + 'err.foo = \'bar\'; throw err; })()', + expected: 'Thrown:\n{ Error: Whoops!\n at repl:1:22 foo: ' + + "\u001b[32m'bar'\u001b[39m }\n", + useColors: true + }, + { command: 'foo = bar;', expected: 'Thrown:\nReferenceError: bar is not defined\n' }, |