Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f5f9b2d

Browse filesBrowse files
committed
test: ensure assertions are reached on more tests
PR-URL: #60728 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 98f5e7c commit f5f9b2d
Copy full SHA for f5f9b2d

83 files changed

+427-463Lines changed: 427 additions & 463 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/eslint.config_partial.mjs‎

Copy file name to clipboardExpand all lines: test/eslint.config_partial.mjs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default [
205205
Array.from({ length: 13 }, (_, i) => String.fromCharCode(0x61 + i, 42)).join(',')
206206
},n*,${
207207
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…'
208-
Array.from({ length: 5 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',')
208+
Array.from({ length: 7 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',')
209209
}}.{js,mjs,cjs}`,
210210
],
211211
rules: {
Collapse file

‎test/parallel/test-tcp-wrap-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tcp-wrap-connect.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Flags: --expose-internals
22
'use strict';
3-
require('../common');
3+
const common = require('../common');
44
const assert = require('assert');
55
const { internalBinding } = require('internal/test/binding');
66
const {
@@ -17,7 +17,7 @@ function makeConnection() {
1717
const err = client.connect(req, '127.0.0.1', this.address().port);
1818
assert.strictEqual(err, 0);
1919

20-
req.oncomplete = function(status, client_, req_, readable, writable) {
20+
req.oncomplete = common.mustCall((status, client_, req_, readable, writable) => {
2121
assert.strictEqual(status, 0);
2222
assert.strictEqual(client_, client);
2323
assert.strictEqual(req_, req);
@@ -28,14 +28,14 @@ function makeConnection() {
2828
const err = client.shutdown(shutdownReq);
2929
assert.strictEqual(err, 0);
3030

31-
shutdownReq.oncomplete = function(status, client_, error) {
31+
shutdownReq.oncomplete = common.mustCall((status, client_, error) => {
3232
assert.strictEqual(status, 0);
3333
assert.strictEqual(client_, client);
3434
assert.strictEqual(error, undefined);
3535
shutdownCount++;
3636
client.close();
37-
};
38-
};
37+
});
38+
});
3939
}
4040

4141
let connectCount = 0;
Collapse file

‎test/parallel/test-tcp-wrap-listen.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tcp-wrap-listen.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ server.getsockname(port);
2424

2525
server.listen(128);
2626

27-
server.onconnection = (err, client) => {
27+
server.onconnection = common.mustCall((err, client) => {
2828
assert.strictEqual(client.writeQueueSize, 0);
2929
console.log('got connection');
3030

@@ -82,7 +82,7 @@ server.onconnection = (err, client) => {
8282
maybeCloseClient();
8383
}
8484
}, 2);
85-
};
85+
});
8686

8787
const net = require('net');
8888

Collapse file

‎test/parallel/test-timers-immediate-queue-throw.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-immediate-queue-throw.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ process.once('uncaughtException', common.mustCall((err, errorOrigin) => {
3131

3232
const d1 = domain.create();
3333
d1.once('error', common.expectsError(errObj));
34-
d1.once('error', () => assert.strictEqual(stage, 0));
34+
d1.once('error', common.mustCall(() => assert.strictEqual(stage, 0)));
3535

3636
const run = common.mustCall((callStage) => {
3737
assert(callStage >= stage);
Collapse file

‎test/parallel/test-timers-interval-promisified.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-interval-promisified.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const { setInterval } = timerPromises;
196196
const { signal } = controller;
197197
const delay = 10;
198198
let totalIterations = 0;
199-
const timeoutLoop = runInterval(async (iterationNumber) => {
199+
const timeoutLoop = runInterval(common.mustCallAtLeast(async (iterationNumber) => {
200200
await setPromiseTimeout(delay * 4);
201201
if (iterationNumber <= 2) {
202202
assert.strictEqual(signal.aborted, false);
@@ -210,7 +210,7 @@ const { setInterval } = timerPromises;
210210
if (iterationNumber > totalIterations) {
211211
totalIterations = iterationNumber;
212212
}
213-
}, delay, signal);
213+
}, 0), delay, signal);
214214

215215
timeoutLoop.catch(common.mustCall(() => {
216216
assert.ok(totalIterations >= 3, `iterations was ${totalIterations} < 3`);
Collapse file

‎test/parallel/test-timers-promises-scheduler.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-promises-scheduler.js
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ const common = require('../common');
44

55
const { scheduler } = require('timers/promises');
66
const { setTimeout } = require('timers');
7-
const {
8-
strictEqual,
9-
rejects,
10-
throws,
11-
} = require('assert');
7+
const assert = require('assert');
128

139
async function testYield() {
1410
await scheduler.yield();
@@ -23,7 +19,7 @@ async function testWait() {
2319
let value = 0;
2420
setTimeout(() => value++, 10);
2521
await scheduler.wait(15);
26-
strictEqual(value, 1);
22+
assert.strictEqual(value, 1);
2723
}
2824

2925
testWait().then(common.mustCall());
@@ -32,7 +28,7 @@ async function testCancelableWait1() {
3228
const ac = new AbortController();
3329
const wait = scheduler.wait(1e6, { signal: ac.signal });
3430
ac.abort();
35-
await rejects(wait, {
31+
await assert.rejects(wait, {
3632
code: 'ABORT_ERR',
3733
message: 'The operation was aborted',
3834
});
@@ -42,14 +38,14 @@ testCancelableWait1().then(common.mustCall());
4238

4339
async function testCancelableWait2() {
4440
const wait = scheduler.wait(10000, { signal: AbortSignal.abort() });
45-
await rejects(wait, {
41+
await assert.rejects(wait, {
4642
code: 'ABORT_ERR',
4743
message: 'The operation was aborted',
4844
});
4945
}
5046

5147
testCancelableWait2().then(common.mustCall());
5248

53-
throws(() => new scheduler.constructor(), {
49+
assert.throws(() => new scheduler.constructor(), {
5450
code: 'ERR_ILLEGAL_CONSTRUCTOR',
5551
});
Collapse file

‎test/parallel/test-timers-refresh.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-refresh.js
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const common = require('../common');
66

7-
const { strictEqual, throws } = require('assert');
7+
const assert = require('assert');
88
const { setUnrefTimeout } = require('internal/timers');
99

1010
// Schedule the unrefed cases first so that the later case keeps the event loop
@@ -24,16 +24,16 @@ const { setUnrefTimeout } = require('internal/timers');
2424
// This relies on implicit timers handle sorting within libuv.
2525

2626
setTimeout(common.mustCall(() => {
27-
strictEqual(called, false, 'unref()\'d timer returned before check');
27+
assert.strictEqual(called, false);
2828
}), 1);
2929

30-
strictEqual(timer.refresh(), timer);
30+
assert.strictEqual(timer.refresh(), timer);
3131
}
3232

3333
// Should throw with non-functions
3434
{
3535
[null, true, false, 0, 1, NaN, '', 'foo', {}, Symbol()].forEach((cb) => {
36-
throws(
36+
assert.throws(
3737
() => setUnrefTimeout(cb),
3838
{
3939
code: 'ERR_INVALID_ARG_TYPE',
@@ -50,10 +50,10 @@ const { setUnrefTimeout } = require('internal/timers');
5050
}), 1);
5151

5252
setUnrefTimeout(common.mustCall(() => {
53-
strictEqual(called, false, 'unref pooled timer returned before check');
53+
assert.strictEqual(called, false);
5454
}), 1);
5555

56-
strictEqual(timer.refresh(), timer);
56+
assert.strictEqual(timer.refresh(), timer);
5757
}
5858

5959
// regular timer
@@ -64,10 +64,10 @@ const { setUnrefTimeout } = require('internal/timers');
6464
}), 1);
6565

6666
setTimeout(common.mustCall(() => {
67-
strictEqual(called, false, 'pooled timer returned before check');
67+
assert.strictEqual(called, false);
6868
}), 1);
6969

70-
strictEqual(timer.refresh(), timer);
70+
assert.strictEqual(timer.refresh(), timer);
7171
}
7272

7373
// regular timer
@@ -78,7 +78,7 @@ const { setUnrefTimeout } = require('internal/timers');
7878
called = true;
7979
process.nextTick(common.mustCall(() => {
8080
timer.refresh();
81-
strictEqual(timer.hasRef(), true);
81+
assert.strictEqual(timer.hasRef(), true);
8282
}));
8383
}
8484
}, 2), 1);
@@ -95,8 +95,8 @@ const { setUnrefTimeout } = require('internal/timers');
9595
}, 2), 1);
9696

9797
setTimeout(common.mustCall(() => {
98-
strictEqual(called, 0, 'pooled timer returned before check');
98+
assert.strictEqual(called, 0);
9999
}), 1);
100100

101-
strictEqual(timer.refresh(), timer);
101+
assert.strictEqual(timer.refresh(), timer);
102102
}
Collapse file

‎test/parallel/test-timers-unref-throw-then-ref.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-unref-throw-then-ref.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ process.once('uncaughtException', common.mustCall((err) => {
99
}));
1010

1111
let called = false;
12-
const t = setTimeout(() => {
12+
const t = setTimeout(common.mustCall(() => {
1313
assert(!called);
1414
called = true;
1515
t.ref();
1616
throw new Error('Timeout Error');
17-
}, 1).unref();
17+
}), 1).unref();
1818

1919
setTimeout(common.mustCall(), 1);
Collapse file

‎test/parallel/test-timers-user-call.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-user-call.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ const common = require('../common');
2525
}
2626

2727
{
28-
const testInterval = (...args) => {
28+
const testInterval = common.mustCall((...args) => {
2929
const fn = common.mustCall(() => { clearInterval(interval); });
3030
fn.call = 'not a function';
3131
fn.apply = 'also not a function';
3232
const interval = setInterval(fn, 1, ...args);
33-
};
33+
}, 5);
3434

3535
testInterval();
3636
testInterval('oneArg');
Collapse file

‎test/parallel/test-tls-add-context.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-add-context.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const serverOptions = {
2222

2323
let connections = 0;
2424

25-
const server = tls.createServer(serverOptions, (c) => {
25+
const server = tls.createServer(serverOptions, common.mustCall((c) => {
2626
if (++connections === 3) {
2727
server.close();
2828
}
@@ -31,7 +31,7 @@ const server = tls.createServer(serverOptions, (c) => {
3131
return;
3232
}
3333
assert.strictEqual(c.authorized, true);
34-
});
34+
}, 3));
3535

3636
const secureContext = {
3737
key: loadPEM('agent1-key'),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.