11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst Duplex = require('stream').Duplex; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci{ 81cb0ef41Sopenharmony_ci const stream = new Duplex({ 91cb0ef41Sopenharmony_ci read() {} 101cb0ef41Sopenharmony_ci }); 111cb0ef41Sopenharmony_ci assert.strictEqual(stream.allowHalfOpen, true); 121cb0ef41Sopenharmony_ci stream.on('finish', common.mustNotCall()); 131cb0ef41Sopenharmony_ci assert.strictEqual(stream.listenerCount('end'), 0); 141cb0ef41Sopenharmony_ci stream.resume(); 151cb0ef41Sopenharmony_ci stream.push(null); 161cb0ef41Sopenharmony_ci} 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci{ 191cb0ef41Sopenharmony_ci const stream = new Duplex({ 201cb0ef41Sopenharmony_ci read() {}, 211cb0ef41Sopenharmony_ci allowHalfOpen: false 221cb0ef41Sopenharmony_ci }); 231cb0ef41Sopenharmony_ci assert.strictEqual(stream.allowHalfOpen, false); 241cb0ef41Sopenharmony_ci stream.on('finish', common.mustCall()); 251cb0ef41Sopenharmony_ci assert.strictEqual(stream.listenerCount('end'), 0); 261cb0ef41Sopenharmony_ci stream.resume(); 271cb0ef41Sopenharmony_ci stream.push(null); 281cb0ef41Sopenharmony_ci} 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci{ 311cb0ef41Sopenharmony_ci const stream = new Duplex({ 321cb0ef41Sopenharmony_ci read() {}, 331cb0ef41Sopenharmony_ci allowHalfOpen: false 341cb0ef41Sopenharmony_ci }); 351cb0ef41Sopenharmony_ci assert.strictEqual(stream.allowHalfOpen, false); 361cb0ef41Sopenharmony_ci stream._writableState.ended = true; 371cb0ef41Sopenharmony_ci stream.on('finish', common.mustNotCall()); 381cb0ef41Sopenharmony_ci assert.strictEqual(stream.listenerCount('end'), 0); 391cb0ef41Sopenharmony_ci stream.resume(); 401cb0ef41Sopenharmony_ci stream.push(null); 411cb0ef41Sopenharmony_ci} 42