mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
3 more passing tests. yaayy
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const { Duplex } = require('stream');
|
||||
const assert = require('assert');
|
||||
|
||||
{
|
||||
const duplex = new Duplex({
|
||||
readable: false
|
||||
});
|
||||
assert.strictEqual(duplex.readable, false);
|
||||
duplex.push('asd');
|
||||
duplex.on('error', common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ERR_STREAM_PUSH_AFTER_EOF');
|
||||
}));
|
||||
duplex.on('data', common.mustNotCall());
|
||||
duplex.on('end', common.mustNotCall());
|
||||
}
|
||||
|
||||
{
|
||||
const duplex = new Duplex({
|
||||
writable: false,
|
||||
write: common.mustNotCall()
|
||||
});
|
||||
assert.strictEqual(duplex.writable, false);
|
||||
duplex.write('asd');
|
||||
duplex.on('error', common.mustCall((err) => {
|
||||
assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END');
|
||||
}));
|
||||
duplex.on('finish', common.mustNotCall());
|
||||
}
|
||||
|
||||
{
|
||||
const duplex = new Duplex({
|
||||
readable: false
|
||||
});
|
||||
assert.strictEqual(duplex.readable, false);
|
||||
duplex.on('data', common.mustNotCall());
|
||||
duplex.on('end', common.mustNotCall());
|
||||
async function run() {
|
||||
for await (const chunk of duplex) {
|
||||
assert(false, chunk);
|
||||
}
|
||||
}
|
||||
run().then(common.mustCall());
|
||||
}
|
||||
19
test/js/node/test/parallel/test-stream-error-once.js
Normal file
19
test/js/node/test/parallel/test-stream-error-once.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const { Writable, Readable } = require('stream');
|
||||
|
||||
{
|
||||
const writable = new Writable();
|
||||
writable.on('error', common.mustCall());
|
||||
writable.end();
|
||||
writable.write('h');
|
||||
writable.write('h');
|
||||
}
|
||||
|
||||
{
|
||||
const readable = new Readable();
|
||||
readable.on('error', common.mustCall());
|
||||
readable.push(null);
|
||||
readable.push('h');
|
||||
readable.push('h');
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const { Writable } = require('stream');
|
||||
|
||||
{
|
||||
// Sync + Sync
|
||||
const writable = new Writable({
|
||||
write: common.mustCall((buf, enc, cb) => {
|
||||
cb();
|
||||
cb();
|
||||
})
|
||||
});
|
||||
writable.write('hi');
|
||||
writable.on('error', common.expectsError({
|
||||
code: 'ERR_MULTIPLE_CALLBACK',
|
||||
name: 'Error'
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
// Sync + Async
|
||||
const writable = new Writable({
|
||||
write: common.mustCall((buf, enc, cb) => {
|
||||
cb();
|
||||
process.nextTick(() => {
|
||||
cb();
|
||||
});
|
||||
})
|
||||
});
|
||||
writable.write('hi');
|
||||
writable.on('error', common.expectsError({
|
||||
code: 'ERR_MULTIPLE_CALLBACK',
|
||||
name: 'Error'
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
// Async + Async
|
||||
const writable = new Writable({
|
||||
write: common.mustCall((buf, enc, cb) => {
|
||||
process.nextTick(cb);
|
||||
process.nextTick(() => {
|
||||
cb();
|
||||
});
|
||||
})
|
||||
});
|
||||
writable.write('hi');
|
||||
writable.on('error', common.expectsError({
|
||||
code: 'ERR_MULTIPLE_CALLBACK',
|
||||
name: 'Error'
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user