11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst { Writable } = require('stream');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci{
81cb0ef41Sopenharmony_ci  const w = new Writable({
91cb0ef41Sopenharmony_ci    write() {}
101cb0ef41Sopenharmony_ci  });
111cb0ef41Sopenharmony_ci  assert.strictEqual(w.writable, true);
121cb0ef41Sopenharmony_ci  w.destroy();
131cb0ef41Sopenharmony_ci  assert.strictEqual(w.writable, false);
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci{
171cb0ef41Sopenharmony_ci  const w = new Writable({
181cb0ef41Sopenharmony_ci    write: common.mustCall((chunk, encoding, callback) => {
191cb0ef41Sopenharmony_ci      callback(new Error());
201cb0ef41Sopenharmony_ci    })
211cb0ef41Sopenharmony_ci  });
221cb0ef41Sopenharmony_ci  assert.strictEqual(w.writable, true);
231cb0ef41Sopenharmony_ci  w.write('asd');
241cb0ef41Sopenharmony_ci  assert.strictEqual(w.writable, false);
251cb0ef41Sopenharmony_ci  w.on('error', common.mustCall());
261cb0ef41Sopenharmony_ci}
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci{
291cb0ef41Sopenharmony_ci  const w = new Writable({
301cb0ef41Sopenharmony_ci    write: common.mustCall((chunk, encoding, callback) => {
311cb0ef41Sopenharmony_ci      process.nextTick(() => {
321cb0ef41Sopenharmony_ci        callback(new Error());
331cb0ef41Sopenharmony_ci        assert.strictEqual(w.writable, false);
341cb0ef41Sopenharmony_ci      });
351cb0ef41Sopenharmony_ci    })
361cb0ef41Sopenharmony_ci  });
371cb0ef41Sopenharmony_ci  w.write('asd');
381cb0ef41Sopenharmony_ci  w.on('error', common.mustCall());
391cb0ef41Sopenharmony_ci}
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci{
421cb0ef41Sopenharmony_ci  const w = new Writable({
431cb0ef41Sopenharmony_ci    write: common.mustNotCall()
441cb0ef41Sopenharmony_ci  });
451cb0ef41Sopenharmony_ci  assert.strictEqual(w.writable, true);
461cb0ef41Sopenharmony_ci  w.end();
471cb0ef41Sopenharmony_ci  assert.strictEqual(w.writable, false);
481cb0ef41Sopenharmony_ci}
49