2018-12-19 14:14:57 -08:00
|
|
|
// Flags: --expose-internals
|
2015-12-05 16:03:30 -05:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
2018-12-19 14:14:57 -08:00
|
|
|
const StreamWrap = require('internal/js_stream_socket');
|
2015-12-05 16:03:30 -05:00
|
|
|
const Duplex = require('stream').Duplex;
|
|
|
|
|
2017-06-22 02:38:41 +02:00
|
|
|
{
|
|
|
|
const stream = new Duplex({
|
|
|
|
read() {},
|
|
|
|
write() {}
|
|
|
|
});
|
2015-12-05 16:03:30 -05:00
|
|
|
|
2017-06-22 02:38:41 +02:00
|
|
|
stream.setEncoding('ascii');
|
2015-12-05 16:03:30 -05:00
|
|
|
|
2017-06-22 02:38:41 +02:00
|
|
|
const wrap = new StreamWrap(stream);
|
2015-12-05 16:03:30 -05:00
|
|
|
|
2017-06-22 02:38:41 +02:00
|
|
|
wrap.on('error', common.expectsError({
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'Error',
|
2017-06-22 02:38:41 +02:00
|
|
|
code: 'ERR_STREAM_WRAP',
|
|
|
|
message: 'Stream has StringDecoder set or is in objectMode'
|
|
|
|
}));
|
2015-12-05 16:03:30 -05:00
|
|
|
|
2017-06-22 02:38:41 +02:00
|
|
|
stream.push('ohai');
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const stream = new Duplex({
|
|
|
|
read() {},
|
|
|
|
write() {},
|
|
|
|
objectMode: true
|
|
|
|
});
|
|
|
|
|
|
|
|
const wrap = new StreamWrap(stream);
|
|
|
|
|
|
|
|
wrap.on('error', common.expectsError({
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'Error',
|
2017-06-22 02:38:41 +02:00
|
|
|
code: 'ERR_STREAM_WRAP',
|
|
|
|
message: 'Stream has StringDecoder set or is in objectMode'
|
|
|
|
}));
|
|
|
|
|
|
|
|
stream.push(new Error('foo'));
|
|
|
|
}
|