@@ -4,20 +4,49 @@ const common = require('../common');
44const stream = require ( 'stream' ) ;
55const assert = require ( 'assert' ) ;
66
7- const transform = new stream . Transform ( {
8- transform : _transform ,
9- highWaterMark : 1
10- } ) ;
11-
12- function _transform ( chunk , encoding , cb ) {
13- assert . strictEqual ( transform . _writableState . needDrain , true ) ;
14- cb ( ) ;
15- }
7+ {
8+ const transform = new stream . Transform ( {
9+ transform : _transform ,
10+ highWaterMark : 1
11+ } ) ;
12+
13+ function _transform ( chunk , encoding , cb ) {
14+ assert . strictEqual ( transform . _writableState . needDrain , false ) ;
15+ cb ( ) ;
16+ }
17+
18+ assert . strictEqual ( transform . _writableState . needDrain , false ) ;
1619
17- assert . strictEqual ( transform . _writableState . needDrain , false ) ;
20+ transform . write ( 'asdasd' , common . mustCall ( ( ) => {
21+ assert . strictEqual ( transform . _writableState . needDrain , false ) ;
22+ } ) ) ;
1823
19- transform . write ( 'asdasd' , common . mustCall ( ( ) => {
2024 assert . strictEqual ( transform . _writableState . needDrain , false ) ;
21- } ) ) ;
25+ }
26+
27+ {
28+ const w = new stream . Writable ( {
29+ highWaterMark : 1
30+ } ) ;
31+
32+ w . _write = ( chunk , encoding , cb ) => {
33+ cb ( ) ;
34+ } ;
35+ w . on ( 'drain' , common . mustNotCall ( ) ) ;
2236
23- assert . strictEqual ( transform . _writableState . needDrain , true ) ;
37+ assert . strictEqual ( w . write ( 'asd' ) , true ) ;
38+ }
39+
40+
41+ {
42+ const w = new stream . Writable ( {
43+ highWaterMark : 1
44+ } ) ;
45+
46+ w . _write = ( chunk , encoding , cb ) => {
47+ process . nextTick ( cb ) ;
48+ } ;
49+ w . on ( 'drain' , common . mustCall ( ) ) ;
50+
51+ assert . strictEqual ( w . write ( 'asd' ) , false ) ;
52+ }
0 commit comments