11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst { Console } = require('console'); 41cb0ef41Sopenharmony_ciconst { Writable } = require('stream'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cifor (const method of ['dir', 'log', 'warn']) { 71cb0ef41Sopenharmony_ci { 81cb0ef41Sopenharmony_ci const out = new Writable({ 91cb0ef41Sopenharmony_ci write: common.mustCall((chunk, enc, callback) => { 101cb0ef41Sopenharmony_ci callback(new Error('foobar')); 111cb0ef41Sopenharmony_ci }) 121cb0ef41Sopenharmony_ci }); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci const c = new Console(out, out, true); 151cb0ef41Sopenharmony_ci c[method]('abc'); // Should not throw. 161cb0ef41Sopenharmony_ci } 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci { 191cb0ef41Sopenharmony_ci const out = new Writable({ 201cb0ef41Sopenharmony_ci write: common.mustCall((chunk, enc, callback) => { 211cb0ef41Sopenharmony_ci throw new Error('foobar'); 221cb0ef41Sopenharmony_ci }) 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci const c = new Console(out, out, true); 261cb0ef41Sopenharmony_ci c[method]('abc'); // Should not throw. 271cb0ef41Sopenharmony_ci } 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci { 301cb0ef41Sopenharmony_ci const out = new Writable({ 311cb0ef41Sopenharmony_ci write: common.mustCall((chunk, enc, callback) => { 321cb0ef41Sopenharmony_ci setImmediate(() => callback(new Error('foobar'))); 331cb0ef41Sopenharmony_ci }) 341cb0ef41Sopenharmony_ci }); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci const c = new Console(out, out, true); 371cb0ef41Sopenharmony_ci c[method]('abc'); // Should not throw. 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci} 40