Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/eslint.config_partial.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default [
`test/parallel/test-{${
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'a*,b*,…'
Array.from({ length: 7 }, (_, i) => String.fromCharCode(0x61 + i, 42)).join(',')
},http-*,http2-*,${
},http-*,http2-*,r*,${
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…'
Array.from({ length: 7 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',')
}}.{js,mjs,cjs}`,
Expand Down
24 changes: 10 additions & 14 deletions test/parallel/test-readable-from-iterator-closing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { mustCall, mustNotCall } = require('../common');
const { Readable } = require('stream');
const { strictEqual } = require('assert');
const assert = require('assert');

async function asyncSupport() {
const finallyMustCall = mustCall();
Expand All @@ -20,7 +20,7 @@ async function asyncSupport() {

for await (const chunk of stream) {
bodyMustCall();
strictEqual(chunk, 'a');
assert.strictEqual(chunk, 'a');
break;
}
}
Expand All @@ -41,7 +41,7 @@ async function syncSupport() {

for await (const chunk of stream) {
bodyMustCall();
strictEqual(chunk, 'a');
assert.strictEqual(chunk, 'a');
break;
}
}
Expand All @@ -66,7 +66,7 @@ async function syncPromiseSupport() {

for await (const chunk of stream) {
bodyMustCall();
strictEqual(chunk, 'a');
assert.strictEqual(chunk, 'a');
break;
}
}
Expand Down Expand Up @@ -130,7 +130,6 @@ async function noReturnAfterThrow() {

async function closeStreamWhileNextIsPending() {
const finallyMustCall = mustCall();
const dataMustCall = mustCall();

let resolveDestroy;
const destroyed =
Expand All @@ -153,10 +152,9 @@ async function closeStreamWhileNextIsPending() {

const stream = Readable.from(infiniteGenerate());

stream.on('data', (data) => {
dataMustCall();
strictEqual(data, 'a');
});
stream.on('data', mustCall((data) => {
assert.strictEqual(data, 'a');
}));

yielded.then(() => {
stream.destroy();
Expand All @@ -166,7 +164,6 @@ async function closeStreamWhileNextIsPending() {

async function closeAfterNullYielded() {
const finallyMustCall = mustCall();
const dataMustCall = mustCall(3);

function* generate() {
try {
Expand All @@ -180,10 +177,9 @@ async function closeAfterNullYielded() {

const stream = Readable.from(generate());

stream.on('data', (chunk) => {
dataMustCall();
strictEqual(chunk, 'a');
});
stream.on('data', mustCall((chunk) => {
assert.strictEqual(chunk, 'a');
}, 3));
}

Promise.all([
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-readable-from-web-enqueue-then-close.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const { mustCall } = require('../common');
const { Readable, Duplex } = require('stream');
const { strictEqual } = require('assert');
const assert = require('assert');

function start(controller) {
controller.enqueue(new Uint8Array(1));
Expand All @@ -10,7 +10,7 @@ function start(controller) {

Readable.fromWeb(new ReadableStream({ start }))
.on('data', mustCall((d) => {
strictEqual(d.length, 1);
assert.strictEqual(d.length, 1);
}))
.on('end', mustCall())
.resume();
Expand All @@ -20,7 +20,7 @@ Duplex.fromWeb({
writable: new WritableStream({ write(chunk) {} })
})
.on('data', mustCall((d) => {
strictEqual(d.length, 1);
assert.strictEqual(d.length, 1);
}))
.on('end', mustCall())
.resume();
46 changes: 23 additions & 23 deletions test/parallel/test-readable-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const { mustCall } = require('../common');
const { once } = require('events');
const { Readable } = require('stream');
const { strictEqual, throws } = require('assert');
const assert = require('assert');
const common = require('../common');

{
throws(() => {
assert.throws(() => {
Readable.from(null);
}, /ERR_INVALID_ARG_TYPE/);
}
Expand All @@ -24,7 +24,7 @@ async function toReadableBasicSupport() {
const expected = ['a', 'b', 'c'];

for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
assert.strictEqual(chunk, expected.shift());
}
}

Expand All @@ -40,7 +40,7 @@ async function toReadableSyncIterator() {
const expected = ['a', 'b', 'c'];

for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
assert.strictEqual(chunk, expected.shift());
}
}

Expand All @@ -56,7 +56,7 @@ async function toReadablePromises() {
const expected = ['a', 'b', 'c'];

for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
assert.strictEqual(chunk, expected.shift());
}
}

Expand All @@ -66,7 +66,7 @@ async function toReadableString() {
const expected = ['abc'];

for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
assert.strictEqual(chunk, expected.shift());
}
}

Expand All @@ -76,7 +76,7 @@ async function toReadableBuffer() {
const expected = ['abc'];

for await (const chunk of stream) {
strictEqual(chunk.toString(), expected.shift());
assert.strictEqual(chunk.toString(), expected.shift());
}
}

Expand All @@ -92,14 +92,14 @@ async function toReadableOnData() {
let iterations = 0;
const expected = ['a', 'b', 'c'];

stream.on('data', (chunk) => {
stream.on('data', common.mustCallAtLeast((chunk) => {
iterations++;
strictEqual(chunk, expected.shift());
});
assert.strictEqual(chunk, expected.shift());
}));

await once(stream, 'end');

strictEqual(iterations, 3);
assert.strictEqual(iterations, 3);
}

async function toReadableOnDataNonObject() {
Expand All @@ -114,15 +114,15 @@ async function toReadableOnDataNonObject() {
let iterations = 0;
const expected = ['a', 'b', 'c'];

stream.on('data', (chunk) => {
stream.on('data', common.mustCallAtLeast((chunk) => {
iterations++;
strictEqual(chunk instanceof Buffer, true);
strictEqual(chunk.toString(), expected.shift());
});
assert.strictEqual(chunk instanceof Buffer, true);
assert.strictEqual(chunk.toString(), expected.shift());
}));

await once(stream, 'end');

strictEqual(iterations, 3);
assert.strictEqual(iterations, 3);
}

async function destroysTheStreamWhenThrowing() {
Expand All @@ -135,8 +135,8 @@ async function destroysTheStreamWhenThrowing() {
stream.read();

const [err] = await once(stream, 'error');
strictEqual(err.message, 'kaboom');
strictEqual(stream.destroyed, true);
assert.strictEqual(err.message, 'kaboom');
assert.strictEqual(stream.destroyed, true);

}

Expand All @@ -162,7 +162,7 @@ async function asTransformStream() {
const expected = ['A', 'B', 'C'];

for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
assert.strictEqual(chunk, expected.shift());
}
}

Expand All @@ -179,18 +179,18 @@ async function endWithError() {

try {
for await (const chunk of stream) {
strictEqual(chunk, expected.shift());
assert.strictEqual(chunk, expected.shift());
}
throw new Error();
} catch (err) {
strictEqual(expected.length, 0);
strictEqual(err, 'Boum');
assert.strictEqual(expected.length, 0);
assert.strictEqual(err, 'Boum');
}
}

async function destroyingStreamWithErrorThrowsInGenerator() {
const validateError = common.mustCall((e) => {
strictEqual(e, 'Boum');
assert.strictEqual(e, 'Boum');
});
async function* generate() {
try {
Expand Down
16 changes: 8 additions & 8 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ function assertCursorRowsAndCols(rli, rows, cols) {
const expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
// ['foo', 'baz', 'bar', bat'];
let callCount = 0;
rli.on('line', (line) => {
rli.on('line', common.mustCallAtLeast((line) => {
assert.strictEqual(line, expectedLines[callCount]);
callCount++;
});
}));
fi.emit('data', `${expectedLines.join('\n')}\n`);
assert.strictEqual(callCount, expectedLines.length);
fi.emit('keypress', '.', { name: 'up' }); // 'bat'
Expand Down Expand Up @@ -360,10 +360,10 @@ function assertCursorRowsAndCols(rli, rows, cols) {
});
const expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat'];
let callCount = 0;
rli.on('line', (line) => {
rli.on('line', common.mustCallAtLeast((line) => {
assert.strictEqual(line, expectedLines[callCount]);
callCount++;
});
}));
fi.emit('data', `${expectedLines.join('\n')}\n`);
assert.strictEqual(callCount, expectedLines.length);
fi.emit('keypress', '.', { name: 'up' }); // 'bat'
Expand Down Expand Up @@ -968,10 +968,10 @@ for (let i = 0; i < 12; i++) {
{
const [rli, fi] = getInterface({ terminal });
let called = false;
rli.on('line', (line) => {
rli.on('line', common.mustCallAtLeast((line) => {
called = true;
assert.strictEqual(line, 'a');
});
}));
fi.emit('data', 'a');
assert.ok(!called);
fi.emit('data', '\n');
Expand Down Expand Up @@ -1020,10 +1020,10 @@ for (let i = 0; i < 12; i++) {
const buf = Buffer.from('☮', 'utf8');
const [rli, fi] = getInterface({ terminal });
let callCount = 0;
rli.on('line', (line) => {
rli.on('line', common.mustCallAtLeast((line) => {
callCount++;
assert.strictEqual(line, buf.toString('utf8'));
});
}));
for (const i of buf) {
fi.emit('data', Buffer.from([i]));
}
Expand Down
18 changes: 9 additions & 9 deletions test/parallel/test-readline-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function addTest(sequences, expectedKeys) {
// (addKeyIntervalTest(..)(noop)))()
// where noop is a terminal function(() => {}).

const addKeyIntervalTest = (sequences, expectedKeys, interval = 550,
assertDelay = 550) => {
const fn = common.mustCall((next) => () => {
function addKeyIntervalTest(sequences, expectedKeys, interval = 550,
assertDelay = 550) {
const fn = common.mustCall((next) => common.mustCall(() => {

if (!Array.isArray(sequences)) {
sequences = [ sequences ];
Expand All @@ -66,21 +66,21 @@ const addKeyIntervalTest = (sequences, expectedKeys, interval = 550,
const keys = [];
fi.on('keypress', (s, k) => keys.push(k));

const emitKeys = ([head, ...tail]) => {
const emitKeys = common.mustCallAtLeast(([head, ...tail]) => {
if (head) {
fi.write(head);
setTimeout(() => emitKeys(tail), interval);
} else {
setTimeout(() => {
setTimeout(common.mustCall(() => {
next();
assert.deepStrictEqual(keys, expectedKeys);
}, assertDelay);
}), assertDelay);
}
};
});
emitKeys(sequences);
});
}));
return fn;
};
}

// Regular alphanumerics
addTest('io.JS', [
Expand Down
Loading
Loading