mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
644fdd60d4
Add punctuation and comments about code that should not throw. Also remove a obsolete test and refactor some tests. PR-URL: https://github.com/nodejs/node/pull/18669 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
40 lines
916 B
JavaScript
40 lines
916 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { Console } = require('console');
|
|
const { Writable } = require('stream');
|
|
|
|
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);
|
|
c[method]('abc'); // Should not throw.
|
|
}
|
|
|
|
{
|
|
const out = new Writable({
|
|
write: common.mustCall((chunk, enc, callback) => {
|
|
throw new Error('foobar');
|
|
})
|
|
});
|
|
|
|
const c = new Console(out, out, true);
|
|
c[method]('abc'); // Should not throw.
|
|
}
|
|
|
|
{
|
|
const out = new Writable({
|
|
write: common.mustCall((chunk, enc, callback) => {
|
|
setImmediate(() => callback(new Error('foobar')));
|
|
})
|
|
});
|
|
|
|
const c = new Console(out, out, true);
|
|
c[method]('abc'); // Should not throw.
|
|
}
|
|
}
|