diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-02-17 18:15:09 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-02-21 16:50:58 +0100 |
commit | c969047d62c90f8c7838342c262b9bf63c72baa3 (patch) | |
tree | 97e0c4bafe01ca209caefe178db58090f4e5fa8e /test | |
parent | 193468667b84b416cd5c5a9f42bc34deedae858e (diff) | |
download | node-new-c969047d62c90f8c7838342c262b9bf63c72baa3.tar.gz |
console: fixup `console.dir()` error handling
Apply the `console: do not emit error events` changes properly
to `console.dir()`.
This was overlooked in f18e08d820dde161788d95a5603546ceca021e90
(https://github.com/nodejs/node/pull/9744).
Ref: https://github.com/nodejs/node/commit/f18e08d820dde161788d95a5603546ceca021e90#commitcomment-20934407
PR-URL: https://github.com/nodejs/node/pull/11443
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-console-async-write-error.js | 20 | ||||
-rw-r--r-- | test/parallel/test-console-sync-write-error.js | 82 |
2 files changed, 53 insertions, 49 deletions
diff --git a/test/parallel/test-console-async-write-error.js b/test/parallel/test-console-async-write-error.js index 0fcd72868a..63e8bfbc88 100644 --- a/test/parallel/test-console-async-write-error.js +++ b/test/parallel/test-console-async-write-error.js @@ -4,14 +4,16 @@ const { Console } = require('console'); const { Writable } = require('stream'); const assert = require('assert'); -const out = new Writable({ - write: common.mustCall((chunk, enc, callback) => { - process.nextTick(callback, new Error('foobar')); - }) -}); +for (const method of ['dir', 'log', 'warn']) { + const out = new Writable({ + write: common.mustCall((chunk, enc, callback) => { + process.nextTick(callback, new Error('foobar')); + }) + }); -const c = new Console(out, out, true); + const c = new Console(out, out, true); -assert.doesNotThrow(() => { - c.log('abc'); -}); + assert.doesNotThrow(() => { + c[method]('abc'); + }); +} diff --git a/test/parallel/test-console-sync-write-error.js b/test/parallel/test-console-sync-write-error.js index 34ff8bad8c..fb350d463b 100644 --- a/test/parallel/test-console-sync-write-error.js +++ b/test/parallel/test-console-sync-write-error.js @@ -4,44 +4,46 @@ const { Console } = require('console'); const { Writable } = require('stream'); const assert = require('assert'); -{ - const out = new Writable({ - write: common.mustCall((chunk, enc, callback) => { - callback(new Error('foobar')); - }) - }); - - const c = new Console(out, out, true); - - assert.doesNotThrow(() => { - c.log('abc'); - }); -} - -{ - const out = new Writable({ - write: common.mustCall((chunk, enc, callback) => { - throw new Error('foobar'); - }) - }); - - const c = new Console(out, out, true); - - assert.doesNotThrow(() => { - c.log('abc'); - }); -} - -{ - const out = new Writable({ - write: common.mustCall((chunk, enc, callback) => { - setImmediate(() => callback(new Error('foobar'))); - }) - }); - - const c = new Console(out, out, true); - - assert.doesNotThrow(() => { - c.log('abc'); - }); +for (const method of ['dir', 'log', 'warn']) { + { + const out = new Writable({ + write: common.mustCall((chunk, enc, callback) => { + callback(new Error('foobar')); + }) + }); + + const c = new Console(out, out, true); + + assert.doesNotThrow(() => { + c[method]('abc'); + }); + } + + { + const out = new Writable({ + write: common.mustCall((chunk, enc, callback) => { + throw new Error('foobar'); + }) + }); + + const c = new Console(out, out, true); + + assert.doesNotThrow(() => { + c[method]('abc'); + }); + } + + { + const out = new Writable({ + write: common.mustCall((chunk, enc, callback) => { + setImmediate(() => callback(new Error('foobar'))); + }) + }); + + const c = new Console(out, out, true); + + assert.doesNotThrow(() => { + c[method]('abc'); + }); + } } |