11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { Writable } = require('stream'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst bufferBlerg = Buffer.from('blerg'); 81cb0ef41Sopenharmony_ciconst w = new Writable(); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciassert.throws( 111cb0ef41Sopenharmony_ci () => { 121cb0ef41Sopenharmony_ci w.end(bufferBlerg); 131cb0ef41Sopenharmony_ci }, 141cb0ef41Sopenharmony_ci { 151cb0ef41Sopenharmony_ci name: 'Error', 161cb0ef41Sopenharmony_ci code: 'ERR_METHOD_NOT_IMPLEMENTED', 171cb0ef41Sopenharmony_ci message: 'The _write() method is not implemented' 181cb0ef41Sopenharmony_ci } 191cb0ef41Sopenharmony_ci); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst _write = common.mustCall((chunk, _, next) => { 221cb0ef41Sopenharmony_ci next(); 231cb0ef41Sopenharmony_ci}); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciconst _writev = common.mustCall((chunks, next) => { 261cb0ef41Sopenharmony_ci assert.strictEqual(chunks.length, 2); 271cb0ef41Sopenharmony_ci next(); 281cb0ef41Sopenharmony_ci}); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciconst w2 = new Writable({ write: _write, writev: _writev }); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ciassert.strictEqual(w2._write, _write); 331cb0ef41Sopenharmony_ciassert.strictEqual(w2._writev, _writev); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ciw2.write(bufferBlerg); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ciw2.cork(); 381cb0ef41Sopenharmony_ciw2.write(bufferBlerg); 391cb0ef41Sopenharmony_ciw2.write(bufferBlerg); 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ciw2.end(); 42