• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const Duplex = require('stream').Duplex;
6
7{
8  const stream = new Duplex({
9    read() {}
10  });
11  assert.strictEqual(stream.allowHalfOpen, true);
12  stream.on('finish', common.mustNotCall());
13  assert.strictEqual(stream.listenerCount('end'), 0);
14  stream.resume();
15  stream.push(null);
16}
17
18{
19  const stream = new Duplex({
20    read() {},
21    allowHalfOpen: false
22  });
23  assert.strictEqual(stream.allowHalfOpen, false);
24  stream.on('finish', common.mustCall());
25  assert.strictEqual(stream.listenerCount('end'), 0);
26  stream.resume();
27  stream.push(null);
28}
29
30{
31  const stream = new Duplex({
32    read() {},
33    allowHalfOpen: false
34  });
35  assert.strictEqual(stream.allowHalfOpen, false);
36  stream._writableState.ended = true;
37  stream.on('finish', common.mustNotCall());
38  assert.strictEqual(stream.listenerCount('end'), 0);
39  stream.resume();
40  stream.push(null);
41}
42