11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst stream = require('stream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_cifunction testWriteType(val, objectMode, code) { 81cb0ef41Sopenharmony_ci const writable = new stream.Writable({ 91cb0ef41Sopenharmony_ci objectMode, 101cb0ef41Sopenharmony_ci write: () => {} 111cb0ef41Sopenharmony_ci }); 121cb0ef41Sopenharmony_ci writable.on('error', common.mustNotCall()); 131cb0ef41Sopenharmony_ci if (code) { 141cb0ef41Sopenharmony_ci assert.throws(() => { 151cb0ef41Sopenharmony_ci writable.write(val); 161cb0ef41Sopenharmony_ci }, { code }); 171cb0ef41Sopenharmony_ci } else { 181cb0ef41Sopenharmony_ci writable.write(val); 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci} 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_citestWriteType([], false, 'ERR_INVALID_ARG_TYPE'); 231cb0ef41Sopenharmony_citestWriteType({}, false, 'ERR_INVALID_ARG_TYPE'); 241cb0ef41Sopenharmony_citestWriteType(0, false, 'ERR_INVALID_ARG_TYPE'); 251cb0ef41Sopenharmony_citestWriteType(true, false, 'ERR_INVALID_ARG_TYPE'); 261cb0ef41Sopenharmony_citestWriteType(0.0, false, 'ERR_INVALID_ARG_TYPE'); 271cb0ef41Sopenharmony_citestWriteType(undefined, false, 'ERR_INVALID_ARG_TYPE'); 281cb0ef41Sopenharmony_citestWriteType(null, false, 'ERR_STREAM_NULL_VALUES'); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_citestWriteType([], true); 311cb0ef41Sopenharmony_citestWriteType({}, true); 321cb0ef41Sopenharmony_citestWriteType(0, true); 331cb0ef41Sopenharmony_citestWriteType(true, true); 341cb0ef41Sopenharmony_citestWriteType(0.0, true); 351cb0ef41Sopenharmony_citestWriteType(undefined, true); 361cb0ef41Sopenharmony_citestWriteType(null, true, 'ERR_STREAM_NULL_VALUES'); 37