11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst { Readable } = require('stream');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci{
81cb0ef41Sopenharmony_ci  const r = new Readable({
91cb0ef41Sopenharmony_ci    read() {}
101cb0ef41Sopenharmony_ci  });
111cb0ef41Sopenharmony_ci  assert.strictEqual(r.readable, true);
121cb0ef41Sopenharmony_ci  r.destroy();
131cb0ef41Sopenharmony_ci  assert.strictEqual(r.readable, false);
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci{
171cb0ef41Sopenharmony_ci  const mustNotCall = common.mustNotCall();
181cb0ef41Sopenharmony_ci  const r = new Readable({
191cb0ef41Sopenharmony_ci    read() {}
201cb0ef41Sopenharmony_ci  });
211cb0ef41Sopenharmony_ci  assert.strictEqual(r.readable, true);
221cb0ef41Sopenharmony_ci  r.on('end', mustNotCall);
231cb0ef41Sopenharmony_ci  r.resume();
241cb0ef41Sopenharmony_ci  r.push(null);
251cb0ef41Sopenharmony_ci  assert.strictEqual(r.readable, true);
261cb0ef41Sopenharmony_ci  r.off('end', mustNotCall);
271cb0ef41Sopenharmony_ci  r.on('end', common.mustCall(() => {
281cb0ef41Sopenharmony_ci    assert.strictEqual(r.readable, false);
291cb0ef41Sopenharmony_ci  }));
301cb0ef41Sopenharmony_ci}
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci{
331cb0ef41Sopenharmony_ci  const r = new Readable({
341cb0ef41Sopenharmony_ci    read: common.mustCall(() => {
351cb0ef41Sopenharmony_ci      process.nextTick(() => {
361cb0ef41Sopenharmony_ci        r.destroy(new Error());
371cb0ef41Sopenharmony_ci        assert.strictEqual(r.readable, false);
381cb0ef41Sopenharmony_ci      });
391cb0ef41Sopenharmony_ci    })
401cb0ef41Sopenharmony_ci  });
411cb0ef41Sopenharmony_ci  r.resume();
421cb0ef41Sopenharmony_ci  r.on('error', common.mustCall(() => {
431cb0ef41Sopenharmony_ci    assert.strictEqual(r.readable, false);
441cb0ef41Sopenharmony_ci  }));
451cb0ef41Sopenharmony_ci}
46