• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4
5const { Readable } = require('stream');
6
7{
8  const r = new Readable({
9    read() {}
10  });
11  assert.strictEqual(r.readable, true);
12  r.destroy();
13  assert.strictEqual(r.readable, false);
14}
15
16{
17  const mustNotCall = common.mustNotCall();
18  const r = new Readable({
19    read() {}
20  });
21  assert.strictEqual(r.readable, true);
22  r.on('end', mustNotCall);
23  r.resume();
24  r.push(null);
25  assert.strictEqual(r.readable, true);
26  r.off('end', mustNotCall);
27  r.on('end', common.mustCall(() => {
28    assert.strictEqual(r.readable, false);
29  }));
30}
31
32{
33  const r = new Readable({
34    read: common.mustCall(() => {
35      process.nextTick(() => {
36        r.destroy(new Error());
37        assert.strictEqual(r.readable, false);
38      });
39    })
40  });
41  r.resume();
42  r.on('error', common.mustCall(() => {
43    assert.strictEqual(r.readable, false);
44  }));
45}
46