11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst StreamWrap = require('internal/js_stream_socket'); 61cb0ef41Sopenharmony_ciconst Duplex = require('stream').Duplex; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci{ 91cb0ef41Sopenharmony_ci const stream = new Duplex({ 101cb0ef41Sopenharmony_ci read() {}, 111cb0ef41Sopenharmony_ci write() {} 121cb0ef41Sopenharmony_ci }); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci stream.setEncoding('ascii'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci const wrap = new StreamWrap(stream); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci wrap.on('error', common.expectsError({ 191cb0ef41Sopenharmony_ci name: 'Error', 201cb0ef41Sopenharmony_ci code: 'ERR_STREAM_WRAP', 211cb0ef41Sopenharmony_ci message: 'Stream has StringDecoder set or is in objectMode' 221cb0ef41Sopenharmony_ci })); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci stream.push('ohai'); 251cb0ef41Sopenharmony_ci} 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci{ 281cb0ef41Sopenharmony_ci const stream = new Duplex({ 291cb0ef41Sopenharmony_ci read() {}, 301cb0ef41Sopenharmony_ci write() {}, 311cb0ef41Sopenharmony_ci objectMode: true 321cb0ef41Sopenharmony_ci }); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci const wrap = new StreamWrap(stream); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci wrap.on('error', common.expectsError({ 371cb0ef41Sopenharmony_ci name: 'Error', 381cb0ef41Sopenharmony_ci code: 'ERR_STREAM_WRAP', 391cb0ef41Sopenharmony_ci message: 'Stream has StringDecoder set or is in objectMode' 401cb0ef41Sopenharmony_ci })); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci stream.push(new Error('foo')); 431cb0ef41Sopenharmony_ci} 44