11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { Duplex } = require('stream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci{ 81cb0ef41Sopenharmony_ci const duplex = new Duplex({ 91cb0ef41Sopenharmony_ci readable: false 101cb0ef41Sopenharmony_ci }); 111cb0ef41Sopenharmony_ci assert.strictEqual(duplex.readable, false); 121cb0ef41Sopenharmony_ci duplex.push('asd'); 131cb0ef41Sopenharmony_ci duplex.on('error', common.mustCall((err) => { 141cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'ERR_STREAM_PUSH_AFTER_EOF'); 151cb0ef41Sopenharmony_ci })); 161cb0ef41Sopenharmony_ci duplex.on('data', common.mustNotCall()); 171cb0ef41Sopenharmony_ci duplex.on('end', common.mustNotCall()); 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci{ 211cb0ef41Sopenharmony_ci const duplex = new Duplex({ 221cb0ef41Sopenharmony_ci writable: false, 231cb0ef41Sopenharmony_ci write: common.mustNotCall() 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci assert.strictEqual(duplex.writable, false); 261cb0ef41Sopenharmony_ci duplex.write('asd'); 271cb0ef41Sopenharmony_ci duplex.on('error', common.mustCall((err) => { 281cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END'); 291cb0ef41Sopenharmony_ci })); 301cb0ef41Sopenharmony_ci duplex.on('finish', common.mustNotCall()); 311cb0ef41Sopenharmony_ci} 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci{ 341cb0ef41Sopenharmony_ci const duplex = new Duplex({ 351cb0ef41Sopenharmony_ci readable: false 361cb0ef41Sopenharmony_ci }); 371cb0ef41Sopenharmony_ci assert.strictEqual(duplex.readable, false); 381cb0ef41Sopenharmony_ci duplex.on('data', common.mustNotCall()); 391cb0ef41Sopenharmony_ci duplex.on('end', common.mustNotCall()); 401cb0ef41Sopenharmony_ci async function run() { 411cb0ef41Sopenharmony_ci for await (const chunk of duplex) { 421cb0ef41Sopenharmony_ci assert(false, chunk); 431cb0ef41Sopenharmony_ci } 441cb0ef41Sopenharmony_ci } 451cb0ef41Sopenharmony_ci run().then(common.mustCall()); 461cb0ef41Sopenharmony_ci} 47