File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
2- require ( '../common' ) ;
2+ const common = require ( '../common' ) ;
33const assert = require ( 'assert' ) ;
44const stream = require ( 'stream' ) ;
55const str = 'asdfasdfasdfasdfasdf' ;
@@ -10,29 +10,25 @@ const r = new stream.Readable({
1010} ) ;
1111
1212let reads = 0 ;
13- let eofed = false ;
14- let ended = false ;
1513
16- r . _read = function ( n ) {
14+ function _read ( ) {
1715 if ( reads === 0 ) {
1816 setTimeout ( function ( ) {
1917 r . push ( str ) ;
20- } ) ;
18+ } , 1 ) ;
2119 reads ++ ;
2220 } else if ( reads === 1 ) {
2321 var ret = r . push ( str ) ;
2422 assert . strictEqual ( ret , false ) ;
2523 reads ++ ;
2624 } else {
27- assert ( ! eofed ) ;
28- eofed = true ;
2925 r . push ( null ) ;
3026 }
31- } ;
27+ }
3228
33- r . on ( 'end' , function ( ) {
34- ended = true ;
35- } ) ;
29+ r . _read = common . mustCall ( _read , 3 ) ;
30+
31+ r . on ( 'end' , common . mustCall ( function ( ) { } ) ) ;
3632
3733// push some data in to start.
3834// we've never gotten any read event at this point.
@@ -55,10 +51,3 @@ r.once('readable', function() {
5551 chunk = r . read ( ) ;
5652 assert . strictEqual ( chunk , null ) ;
5753} ) ;
58-
59- process . on ( 'exit' , function ( ) {
60- assert ( eofed ) ;
61- assert ( ended ) ;
62- assert . strictEqual ( reads , 2 ) ;
63- console . log ( 'ok' ) ;
64- } ) ;
You can’t perform that action at this time.
0 commit comments