11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// This test ensures that Readable stream will continue to call _read 61cb0ef41Sopenharmony_ci// for streams with highWaterMark === 0 once the stream returns data 71cb0ef41Sopenharmony_ci// by calling push() asynchronously. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst { Readable } = require('stream'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cilet count = 5; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst r = new Readable({ 141cb0ef41Sopenharmony_ci // Called 6 times: First 5 return data, last one signals end of stream. 151cb0ef41Sopenharmony_ci read: common.mustCall(() => { 161cb0ef41Sopenharmony_ci process.nextTick(common.mustCall(() => { 171cb0ef41Sopenharmony_ci if (count--) 181cb0ef41Sopenharmony_ci r.push('a'); 191cb0ef41Sopenharmony_ci else 201cb0ef41Sopenharmony_ci r.push(null); 211cb0ef41Sopenharmony_ci })); 221cb0ef41Sopenharmony_ci }, 6), 231cb0ef41Sopenharmony_ci highWaterMark: 0, 241cb0ef41Sopenharmony_ci}); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_cir.on('end', common.mustCall()); 271cb0ef41Sopenharmony_cir.on('data', common.mustCall(5)); 28