GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: ensure assertions are reached on all tests · nodejs/node@8e9aded

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • eslint.config_partial.mjs
    • fixtures/test-runner/output
      • hooks-with-no-global-test.js
    • parallel
      • test-os.js
      • test-perf-hooks-histogram.js
      • test-performance-gc.js
      • test-performance-global.js
      • test-performance-measure.js
      • test-permission-allow-worker-cli.js
      • test-permission-fs-internal-module-stat.js
      • test-pipe-file-to-http.js
      • test-pipe-stream.js
      • test-pipe-writev.js
      • test-preload.js
      • test-process-env-allowed-flags-are-documented.js
      • test-process-env-allowed-flags.js
      • test-process-env-sideeffects.js
      • test-process-execve-abort.js
      • test-process-execve-no-args.js
      • test-process-execve-on-exit.js
      • test-process-execve-permission-fail.js
      • test-process-execve-permission-granted.js
      • test-process-execve-socket.js
      • test-process-execve-validation.js
      • test-process-execve-worker-threads.js
      • test-process-execve.js
      • test-process-exit-code-validation.js
      • test-process-exit-code.js
      • test-process-getgroups.js
      • test-process-raw-debug.js
      • test-process-ref-unref.js
      • test-process-threadCpuUsage-main-thread.js
      • test-process-threadCpuUsage-worker-threads.js
      • test-process-uptime.js
      • test-process-warning.js
      • test-promise-hook-on-resolve.js
      • test-promises-unhandled-rejections.js
      • test-punycode.js
      • test-quic-handshake.js
      • test-quic-internal-endpoint-listen-defaults.js
      • test-quic-internal-endpoint-options.js
      • test-quic-internal-endpoint-stats-state.js

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
+2-50Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export default [
140140
],
141141
'node-core/require-common-first': 'error',
142142
'node-core/no-duplicate-requires': 'off',
143+
'node-core/must-call-assert': 'error',
143144
},
144145
},
145146
{
@@ -161,56 +162,6 @@ export default [
161162
],
162163
},
163164
},
164-
{
165-
files: [
166-
`test/{${[
167-
'abort',
168-
'addons',
169-
'async-hooks',
170-
'benchmark',
171-
'cctest',
172-
'client-proxy',
173-
'doctool',
174-
'embedding',
175-
'es-module',
176-
'fixtures',
177-
'fuzzers',
178-
'internet',
179-
'js-native-api',
180-
'known_issues',
181-
'message',
182-
'module-hooks',
183-
'node-api',
184-
'nop',
185-
'overlapped-checker',
186-
'pseudo-tty',
187-
'pummel',
188-
'report',
189-
'sea',
190-
'sequential',
191-
'sqlite',
192-
'system-ca',
193-
'test426',
194-
'testpy',
195-
'tick-processor',
196-
'tools',
197-
'v8-updates',
198-
'wasi',
199-
'wasm-allocation',
200-
'wpt',
201-
].join(',')}}/**/*.{js,mjs,cjs}`,
202-
`test/parallel/test-{${
203-
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'a*,b*,…'
204-
Array.from({ length: 13 }, (_, i) => String.fromCharCode(0x61 + i, 42)).join(',')
205-
},n*,r*,${
206-
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…'
207-
Array.from({ length: 8 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',')
208-
}}.{js,mjs,cjs}`,
209-
],
210-
rules: {
211-
'node-core/must-call-assert': 'error',
212-
},
213-
},
214165
{
215166
files: [
216167
'test/{common,fixtures,wpt}/**/*.{js,mjs,cjs}',
@@ -219,6 +170,7 @@ export default [
219170
rules: {
220171
'node-core/required-modules': 'off',
221172
'node-core/require-common-first': 'off',
173+
'node-core/must-call-assert': 'off',
222174
},
223175
},
224176
{
Collapse file

‎test/fixtures/test-runner/output/hooks-with-no-global-test.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/hooks-with-no-global-test.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ before(() => testArr.push('global before'));
99
after(() => {
1010
testArr.push('global after');
1111

12-
// eslint-disable-next-line node-core/must-call-assert
1312
assert.deepStrictEqual(testArr, [
1413
'global before',
1514
'describe before',
Collapse file

‎test/parallel/test-os.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-os.js
+13-15Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ const path = require('path');
2727
const { inspect } = require('util');
2828

2929
const is = {
30-
number: (value, key) => {
30+
number: common.mustCallAtLeast((value, key) => {
3131
assert(!Number.isNaN(value), `${key} should not be NaN`);
3232
assert.strictEqual(typeof value, 'number');
33-
},
34-
string: (value) => { assert.strictEqual(typeof value, 'string'); },
35-
array: (value) => { assert.ok(Array.isArray(value)); },
36-
object: (value) => {
33+
}),
34+
string: common.mustCallAtLeast((value) => { assert.strictEqual(typeof value, 'string'); }),
35+
array: common.mustCallAtLeast((value) => { assert.ok(Array.isArray(value)); }),
36+
object: common.mustCallAtLeast((value) => {
3737
assert.strictEqual(typeof value, 'object');
3838
assert.notStrictEqual(value, null);
39-
}
39+
}),
4040
};
4141

4242
process.env.TMPDIR = '/tmpdir';
@@ -181,15 +181,13 @@ const netmaskToCIDRSuffixMap = new Map(Object.entries({
181181
'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff': 128
182182
}));
183183

184-
Object.values(interfaces)
185-
.flat(Infinity)
186-
.map((v) => ({ v, mask: netmaskToCIDRSuffixMap.get(v.netmask) }))
187-
.forEach(({ v, mask }) => {
188-
assert.ok('cidr' in v, `"cidr" prop not found in ${inspect(v)}`);
189-
if (mask) {
190-
assert.strictEqual(v.cidr, `${v.address}/${mask}`);
191-
}
192-
});
184+
for (const v of Object.values(interfaces).flat(Infinity)) {
185+
assert.ok('cidr' in v, `"cidr" prop not found in ${inspect(v)}`);
186+
const mask = netmaskToCIDRSuffixMap.get(v.netmask);
187+
if (mask) {
188+
assert.strictEqual(v.cidr, `${v.address}/${mask}`);
189+
}
190+
}
193191

194192
const EOL = os.EOL;
195193
if (common.isWindows) {
Collapse file

‎test/parallel/test-perf-hooks-histogram.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-perf-hooks-histogram.js
+53-58Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
const common = require('../common');
44

5-
const {
6-
deepStrictEqual,
7-
ok,
8-
strictEqual,
9-
throws,
10-
} = require('assert');
5+
const assert = require('assert');
116

127
const {
138
createHistogram,
@@ -19,64 +14,64 @@ const { inspect } = require('util');
1914
{
2015
const h = createHistogram();
2116

22-
strictEqual(h.min, 9223372036854776000);
23-
strictEqual(h.minBigInt, 9223372036854775807n);
24-
strictEqual(h.max, 0);
25-
strictEqual(h.maxBigInt, 0n);
26-
strictEqual(h.exceeds, 0);
27-
strictEqual(h.exceedsBigInt, 0n);
28-
ok(Number.isNaN(h.mean));
29-
ok(Number.isNaN(h.stddev));
17+
assert.strictEqual(h.min, 9223372036854776000);
18+
assert.strictEqual(h.minBigInt, 9223372036854775807n);
19+
assert.strictEqual(h.max, 0);
20+
assert.strictEqual(h.maxBigInt, 0n);
21+
assert.strictEqual(h.exceeds, 0);
22+
assert.strictEqual(h.exceedsBigInt, 0n);
23+
assert.ok(Number.isNaN(h.mean));
24+
assert.ok(Number.isNaN(h.stddev));
3025

31-
strictEqual(h.count, 0);
32-
strictEqual(h.countBigInt, 0n);
26+
assert.strictEqual(h.count, 0);
27+
assert.strictEqual(h.countBigInt, 0n);
3328

3429
h.record(1);
3530

36-
strictEqual(h.count, 1);
37-
strictEqual(h.countBigInt, 1n);
31+
assert.strictEqual(h.count, 1);
32+
assert.strictEqual(h.countBigInt, 1n);
3833

3934
[false, '', {}, undefined, null].forEach((i) => {
40-
throws(() => h.record(i), {
35+
assert.throws(() => h.record(i), {
4136
code: 'ERR_INVALID_ARG_TYPE'
4237
});
4338
});
4439
[0, Number.MAX_SAFE_INTEGER + 1].forEach((i) => {
45-
throws(() => h.record(i), {
40+
assert.throws(() => h.record(i), {
4641
code: 'ERR_OUT_OF_RANGE'
4742
});
4843
});
4944

50-
strictEqual(h.min, 1);
51-
strictEqual(h.minBigInt, 1n);
52-
strictEqual(h.max, 1);
53-
strictEqual(h.maxBigInt, 1n);
54-
strictEqual(h.exceeds, 0);
55-
strictEqual(h.mean, 1);
56-
strictEqual(h.stddev, 0);
45+
assert.strictEqual(h.min, 1);
46+
assert.strictEqual(h.minBigInt, 1n);
47+
assert.strictEqual(h.max, 1);
48+
assert.strictEqual(h.maxBigInt, 1n);
49+
assert.strictEqual(h.exceeds, 0);
50+
assert.strictEqual(h.mean, 1);
51+
assert.strictEqual(h.stddev, 0);
5752

58-
strictEqual(h.percentile(1), 1);
59-
strictEqual(h.percentile(100), 1);
53+
assert.strictEqual(h.percentile(1), 1);
54+
assert.strictEqual(h.percentile(100), 1);
6055

61-
strictEqual(h.percentileBigInt(1), 1n);
62-
strictEqual(h.percentileBigInt(100), 1n);
56+
assert.strictEqual(h.percentileBigInt(1), 1n);
57+
assert.strictEqual(h.percentileBigInt(100), 1n);
6358

64-
deepStrictEqual(h.percentiles, new Map([[0, 1], [100, 1]]));
59+
assert.deepStrictEqual(h.percentiles, new Map([[0, 1], [100, 1]]));
6560

66-
deepStrictEqual(h.percentilesBigInt, new Map([[0, 1n], [100, 1n]]));
61+
assert.deepStrictEqual(h.percentilesBigInt, new Map([[0, 1n], [100, 1n]]));
6762

6863
const mc = new MessageChannel();
6964
mc.port1.onmessage = common.mustCall(({ data }) => {
70-
strictEqual(h.min, 1);
71-
strictEqual(h.max, 1);
72-
strictEqual(h.exceeds, 0);
73-
strictEqual(h.mean, 1);
74-
strictEqual(h.stddev, 0);
65+
assert.strictEqual(h.min, 1);
66+
assert.strictEqual(h.max, 1);
67+
assert.strictEqual(h.exceeds, 0);
68+
assert.strictEqual(h.mean, 1);
69+
assert.strictEqual(h.stddev, 0);
7570

7671
data.record(2n);
7772
data.recordDelta();
7873

79-
strictEqual(h.max, 2);
74+
assert.strictEqual(h.max, 2);
8075

8176
mc.port1.close();
8277
});
@@ -85,15 +80,15 @@ const { inspect } = require('util');
8580

8681
{
8782
const e = monitorEventLoopDelay();
88-
strictEqual(e.count, 0);
83+
assert.strictEqual(e.count, 0);
8984
e.enable();
9085
const mc = new MessageChannel();
9186
mc.port1.onmessage = common.mustCall(({ data }) => {
92-
strictEqual(typeof data.min, 'number');
93-
ok(data.min > 0);
94-
ok(data.count > 0);
95-
strictEqual(data.disable, undefined);
96-
strictEqual(data.enable, undefined);
87+
assert.strictEqual(typeof data.min, 'number');
88+
assert.ok(data.min > 0);
89+
assert.ok(data.count > 0);
90+
assert.strictEqual(data.disable, undefined);
91+
assert.strictEqual(data.enable, undefined);
9792
mc.port1.close();
9893
});
9994
const interval = setInterval(() => {
@@ -112,19 +107,19 @@ const { inspect } = require('util');
112107
histogram = hi;
113108
}
114109
// The histogram should already be disabled.
115-
strictEqual(histogram.disable(), false);
110+
assert.strictEqual(histogram.disable(), false);
116111
}
117112

118113
{
119114
const h = createHistogram();
120-
ok(inspect(h, { depth: null }).startsWith('Histogram'));
121-
strictEqual(inspect(h, { depth: -1 }), '[RecordableHistogram]');
115+
assert.ok(inspect(h, { depth: null }).startsWith('Histogram'));
116+
assert.strictEqual(inspect(h, { depth: -1 }), '[RecordableHistogram]');
122117
}
123118

124119
{
125120
// Tests that RecordableHistogram is impossible to construct manually
126121
const h = createHistogram();
127-
throws(() => new h.constructor(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' });
122+
assert.throws(() => new h.constructor(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' });
128123
}
129124

130125
{
@@ -133,7 +128,7 @@ const { inspect } = require('util');
133128
1,
134129
null,
135130
].forEach((i) => {
136-
throws(() => createHistogram(i), { code: 'ERR_INVALID_ARG_TYPE' });
131+
assert.throws(() => createHistogram(i), { code: 'ERR_INVALID_ARG_TYPE' });
137132
});
138133

139134
[
@@ -142,20 +137,20 @@ const { inspect } = require('util');
142137
null,
143138
{},
144139
].forEach((i) => {
145-
throws(() => createHistogram({ lowest: i }), {
140+
assert.throws(() => createHistogram({ lowest: i }), {
146141
code: 'ERR_INVALID_ARG_TYPE',
147142
});
148-
throws(() => createHistogram({ highest: i }), {
143+
assert.throws(() => createHistogram({ highest: i }), {
149144
code: 'ERR_INVALID_ARG_TYPE',
150145
});
151-
throws(() => createHistogram({ figures: i }), {
146+
assert.throws(() => createHistogram({ figures: i }), {
152147
code: 'ERR_INVALID_ARG_TYPE',
153148
});
154149
});
155150

156151
// Number greater than 5 is not allowed
157152
for (const i of [6, 10]) {
158-
throws(() => createHistogram({ figures: i }), {
153+
assert.throws(() => createHistogram({ figures: i }), {
159154
code: 'ERR_OUT_OF_RANGE',
160155
});
161156
}
@@ -169,20 +164,20 @@ const { inspect } = require('util');
169164

170165
h1.record(1);
171166

172-
strictEqual(h2.count, 0);
173-
strictEqual(h1.count, 1);
167+
assert.strictEqual(h2.count, 0);
168+
assert.strictEqual(h1.count, 1);
174169

175170
h2.add(h1);
176171

177-
strictEqual(h2.count, 1);
172+
assert.strictEqual(h2.count, 1);
178173

179174
[
180175
'hello',
181176
1,
182177
false,
183178
{},
184179
].forEach((i) => {
185-
throws(() => h1.add(i), {
180+
assert.throws(() => h1.add(i), {
186181
code: 'ERR_INVALID_ARG_TYPE',
187182
});
188183
});
Collapse file

‎test/parallel/test-performance-gc.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-performance-gc.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ const kinds = [
4848
// GC should not keep the event loop alive
4949
{
5050
let didCall = false;
51-
process.on('beforeExit', () => {
51+
process.on('beforeExit', common.mustCall(() => {
5252
assert(!didCall);
5353
didCall = true;
5454
globalThis.gc();
55-
});
55+
}));
5656
}
Collapse file

‎test/parallel/test-performance-global.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-performance-global.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
require('../common');
55

66
const perf_hooks = require('perf_hooks');
7-
const {
8-
strictEqual
9-
} = require('assert');
7+
const assert = require('assert');
108

119
const perf = performance;
12-
strictEqual(globalThis.performance, perf_hooks.performance);
10+
assert.strictEqual(globalThis.performance, perf_hooks.performance);
1311
performance = undefined;
14-
strictEqual(globalThis.performance, undefined);
15-
strictEqual(typeof perf_hooks.performance.now, 'function');
12+
assert.strictEqual(globalThis.performance, undefined);
13+
assert.strictEqual(typeof perf_hooks.performance.now, 'function');
1614

1715
// Restore the value of performance for the known globals check
1816
performance = perf;
Collapse file

‎test/parallel/test-performance-measure.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-performance-measure.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const ALLOWED_MARGIN = 10;
99

1010
const expected = ['Start to Now', 'A to Now', 'A to B'];
1111
const obs = new PerformanceObserver(common.mustCall((items) => {
12-
items.getEntries().forEach(({ name, duration }) => {
12+
for (const { name, duration } of items.getEntries()) {
1313
assert.ok(duration > (DELAY - ALLOWED_MARGIN));
1414
assert.strictEqual(expected.shift(), name);
15-
});
15+
}
1616
}));
1717
obs.observe({ entryTypes: ['measure'] });
1818

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.