File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+ const 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' ) , 1 ) ;
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' ) , 1 ) ;
39
+ stream . resume ( ) ;
40
+ stream . push ( null ) ;
41
+ }
You can’t perform that action at this time.
0 commit comments