| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -194,6 +194,9 @@ export default [ | |||
| 194 | 194 | `test/parallel/test-{${ | |
| 195 | 195 | // 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…' | |
| 196 | 196 | Array.from({ length: 2 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',') | |
| 197 | + },${ | ||
| 198 | + // 0x61 is code for 'a', this generates a string enumerating latin letters: 'a*,b*,…' | ||
| 199 | + Array.from({ length: 2 }, (_, i) => String.fromCharCode(0x61 + i, 42)).join(',') | ||
| 197 | 200 | }}.{js,mjs,cjs}`, | |
| 198 | 201 | ], | |
| 199 | 202 | rules: { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,9 +2,7 @@ | |||
| 2 | 2 | 'use strict'; | |
| 3 | 3 | require('../common'); | |
| 4 | 4 | ||
| 5 | - const { | ||
| 6 | - strictEqual, | ||
| 7 | - } = require('assert'); | ||
| 5 | + const assert = require('assert'); | ||
| 8 | 6 | ||
| 9 | 7 | const { | |
| 10 | 8 | test, | |
@@ -30,5 +28,5 @@ test('A weak event listener should not prevent gc', async () => { | |||
| 30 | 28 | ||
| 31 | 29 | await sleep(10); | |
| 32 | 30 | globalThis.gc(); | |
| 33 | - strictEqual(ref.deref(), undefined); | ||
| 31 | + assert.strictEqual(ref.deref(), undefined); | ||
| 34 | 32 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,10 @@ | |||
| 1 | 1 | // Flags: --expose-gc | |
| 2 | 2 | 'use strict'; | |
| 3 | 3 | ||
| 4 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 5 | 5 | const { inspect } = require('util'); | |
| 6 | 6 | ||
| 7 | - const { | ||
| 8 | - ok, | ||
| 9 | - notStrictEqual, | ||
| 10 | - strictEqual, | ||
| 11 | - throws, | ||
| 12 | - } = require('assert'); | ||
| 7 | + const assert = require('assert'); | ||
| 13 | 8 | ||
| 14 | 9 | const { | |
| 15 | 10 | test, | |
@@ -25,34 +20,34 @@ const { setTimeout: sleep } = require('timers/promises'); | |||
| 25 | 20 | test('Abort is fired with the correct event type on AbortControllers', () => { | |
| 26 | 21 | // Tests that abort is fired with the correct event type on AbortControllers | |
| 27 | 22 | const ac = new AbortController(); | |
| 28 | - ok(ac.signal); | ||
| 23 | + assert.ok(ac.signal); | ||
| 29 | 24 | ||
| 30 | - const fn = mock.fn((event) => { | ||
| 31 | - ok(event); | ||
| 32 | - strictEqual(event.type, 'abort'); | ||
| 33 | - }); | ||
| 25 | + const fn = mock.fn(common.mustCall((event) => { | ||
| 26 | + assert.ok(event); | ||
| 27 | + assert.strictEqual(event.type, 'abort'); | ||
| 28 | + }, 2)); | ||
| 34 | 29 | ||
| 35 | 30 | ac.signal.onabort = fn; | |
| 36 | 31 | ac.signal.addEventListener('abort', fn); | |
| 37 | 32 | ||
| 38 | 33 | ac.abort(); | |
| 39 | 34 | ac.abort(); | |
| 40 | - ok(ac.signal.aborted); | ||
| 35 | + assert.ok(ac.signal.aborted); | ||
| 41 | 36 | ||
| 42 | - strictEqual(fn.mock.calls.length, 2); | ||
| 37 | + assert.strictEqual(fn.mock.calls.length, 2); | ||
| 43 | 38 | }); | |
| 44 | 39 | ||
| 45 | 40 | test('Abort events are trusted', () => { | |
| 46 | 41 | // Tests that abort events are trusted | |
| 47 | 42 | const ac = new AbortController(); | |
| 48 | 43 | ||
| 49 | - const fn = mock.fn((event) => { | ||
| 50 | - ok(event.isTrusted); | ||
| 51 | - }); | ||
| 44 | + const fn = mock.fn(common.mustCall((event) => { | ||
| 45 | + assert.ok(event.isTrusted); | ||
| 46 | + })); | ||
| 52 | 47 | ||
| 53 | 48 | ac.signal.onabort = fn; | |
| 54 | 49 | ac.abort(); | |
| 55 | - strictEqual(fn.mock.calls.length, 1); | ||
| 50 | + assert.strictEqual(fn.mock.calls.length, 1); | ||
| 56 | 51 | }); | |
| 57 | 52 | ||
| 58 | 53 | test('Abort events have the same isTrusted reference', () => { | |
@@ -73,14 +68,14 @@ test('Abort events have the same isTrusted reference', () => { | |||
| 73 | 68 | const firstTrusted = Reflect.getOwnPropertyDescriptor(Object.getPrototypeOf(ev1), 'isTrusted').get; | |
| 74 | 69 | const secondTrusted = Reflect.getOwnPropertyDescriptor(Object.getPrototypeOf(ev2), 'isTrusted').get; | |
| 75 | 70 | const untrusted = Reflect.getOwnPropertyDescriptor(Object.getPrototypeOf(ev3), 'isTrusted').get; | |
| 76 | - strictEqual(firstTrusted, secondTrusted); | ||
| 77 | - strictEqual(untrusted, firstTrusted); | ||
| 71 | + assert.strictEqual(firstTrusted, secondTrusted); | ||
| 72 | + assert.strictEqual(untrusted, firstTrusted); | ||
| 78 | 73 | }); | |
| 79 | 74 | ||
| 80 | 75 | test('AbortSignal is impossible to construct manually', () => { | |
| 81 | 76 | // Tests that AbortSignal is impossible to construct manually | |
| 82 | 77 | const ac = new AbortController(); | |
| 83 | - throws(() => new ac.signal.constructor(), { | ||
| 78 | + assert.throws(() => new ac.signal.constructor(), { | ||
| 84 | 79 | code: 'ERR_ILLEGAL_CONSTRUCTOR', | |
| 85 | 80 | }); | |
| 86 | 81 | }); | |
@@ -89,13 +84,13 @@ test('Symbol.toStringTag is correct', () => { | |||
| 89 | 84 | // Symbol.toStringTag | |
| 90 | 85 | const toString = (o) => Object.prototype.toString.call(o); | |
| 91 | 86 | const ac = new AbortController(); | |
| 92 | - strictEqual(toString(ac), '[object AbortController]'); | ||
| 93 | - strictEqual(toString(ac.signal), '[object AbortSignal]'); | ||
| 87 | + assert.strictEqual(toString(ac), '[object AbortController]'); | ||
| 88 | + assert.strictEqual(toString(ac.signal), '[object AbortSignal]'); | ||
| 94 | 89 | }); | |
| 95 | 90 | ||
| 96 | 91 | test('AbortSignal.abort() creates an already aborted signal', () => { | |
| 97 | 92 | const signal = AbortSignal.abort(); | |
| 98 | - ok(signal.aborted); | ||
| 93 | + assert.ok(signal.aborted); | ||
| 99 | 94 | }); | |
| 100 | 95 | ||
| 101 | 96 | test('AbortController properties and methods valiate the receiver', () => { | |
@@ -106,7 +101,7 @@ test('AbortController properties and methods valiate the receiver', () => { | |||
| 106 | 101 | const acAbort = AbortController.prototype.abort; | |
| 107 | 102 | ||
| 108 | 103 | const goodController = new AbortController(); | |
| 109 | - ok(acSignalGet.call(goodController)); | ||
| 104 | + assert.ok(acSignalGet.call(goodController)); | ||
| 110 | 105 | acAbort.call(goodController); | |
| 111 | 106 | ||
| 112 | 107 | const badAbortControllers = [ | |
@@ -119,11 +114,11 @@ test('AbortController properties and methods valiate the receiver', () => { | |||
| 119 | 114 | { __proto__: AbortController.prototype }, | |
| 120 | 115 | ]; | |
| 121 | 116 | for (const badController of badAbortControllers) { | |
| 122 | - throws( | ||
| 117 | + assert.throws( | ||
| 123 | 118 | () => acSignalGet.call(badController), | |
| 124 | 119 | { name: 'TypeError' } | |
| 125 | 120 | ); | |
| 126 | - throws( | ||
| 121 | + assert.throws( | ||
| 127 | 122 | () => acAbort.call(badController), | |
| 128 | 123 | { name: 'TypeError' } | |
| 129 | 124 | ); | |
@@ -137,7 +132,7 @@ test('AbortSignal properties validate the receiver', () => { | |||
| 137 | 132 | ).get; | |
| 138 | 133 | ||
| 139 | 134 | const goodSignal = new AbortController().signal; | |
| 140 | - strictEqual(signalAbortedGet.call(goodSignal), false); | ||
| 135 | + assert.strictEqual(signalAbortedGet.call(goodSignal), false); | ||
| 141 | 136 | ||
| 142 | 137 | const badAbortSignals = [ | |
| 143 | 138 | null, | |
@@ -149,7 +144,7 @@ test('AbortSignal properties validate the receiver', () => { | |||
| 149 | 144 | { __proto__: AbortSignal.prototype }, | |
| 150 | 145 | ]; | |
| 151 | 146 | for (const badSignal of badAbortSignals) { | |
| 152 | - throws( | ||
| 147 | + assert.throws( | ||
| 153 | 148 | () => signalAbortedGet.call(badSignal), | |
| 154 | 149 | { name: 'TypeError' } | |
| 155 | 150 | ); | |
@@ -158,38 +153,38 @@ test('AbortSignal properties validate the receiver', () => { | |||
| 158 | 153 | ||
| 159 | 154 | test('AbortController inspection depth 1 or null works', () => { | |
| 160 | 155 | const ac = new AbortController(); | |
| 161 | - strictEqual(inspect(ac, { depth: 1 }), | ||
| 162 | - 'AbortController { signal: [AbortSignal] }'); | ||
| 163 | - strictEqual(inspect(ac, { depth: null }), | ||
| 164 | - 'AbortController { signal: AbortSignal { aborted: false } }'); | ||
| 156 | + assert.strictEqual(inspect(ac, { depth: 1 }), | ||
| 157 | + 'AbortController { signal: [AbortSignal] }'); | ||
| 158 | + assert.strictEqual(inspect(ac, { depth: null }), | ||
| 159 | + 'AbortController { signal: AbortSignal { aborted: false } }'); | ||
| 165 | 160 | }); | |
| 166 | 161 | ||
| 167 | 162 | test('AbortSignal reason is set correctly', () => { | |
| 168 | 163 | // Test AbortSignal.reason | |
| 169 | 164 | const ac = new AbortController(); | |
| 170 | 165 | ac.abort('reason'); | |
| 171 | - strictEqual(ac.signal.reason, 'reason'); | ||
| 166 | + assert.strictEqual(ac.signal.reason, 'reason'); | ||
| 172 | 167 | }); | |
| 173 | 168 | ||
| 174 | 169 | test('AbortSignal reasonable is set correctly with AbortSignal.abort()', () => { | |
| 175 | 170 | // Test AbortSignal.reason | |
| 176 | 171 | const signal = AbortSignal.abort('reason'); | |
| 177 | - strictEqual(signal.reason, 'reason'); | ||
| 172 | + assert.strictEqual(signal.reason, 'reason'); | ||
| 178 | 173 | }); | |
| 179 | 174 | ||
| 180 | 175 | test('AbortSignal.timeout() works as expected', async () => { | |
| 181 | 176 | // Test AbortSignal timeout | |
| 182 | 177 | const signal = AbortSignal.timeout(10); | |
| 183 | - ok(!signal.aborted); | ||
| 178 | + assert.ok(!signal.aborted); | ||
| 184 | 179 | ||
| 185 | 180 | const { promise, resolve } = Promise.withResolvers(); | |
| 186 | 181 | ||
| 187 | - const fn = mock.fn(() => { | ||
| 188 | - ok(signal.aborted); | ||
| 189 | - strictEqual(signal.reason.name, 'TimeoutError'); | ||
| 190 | - strictEqual(signal.reason.code, 23); | ||
| 182 | + const fn = mock.fn(common.mustCall(() => { | ||
| 183 | + assert.ok(signal.aborted); | ||
| 184 | + assert.strictEqual(signal.reason.name, 'TimeoutError'); | ||
| 185 | + assert.strictEqual(signal.reason.code, 23); | ||
| 191 | 186 | resolve(); | |
| 192 | - }); | ||
| 187 | + })); | ||
| 193 | 188 | ||
| 194 | 189 | setTimeout(fn, 20); | |
| 195 | 190 | await promise; | |
@@ -205,7 +200,7 @@ test('AbortSignal.timeout() does not prevent the signal from being collected', a | |||
| 205 | 200 | ||
| 206 | 201 | await sleep(10); | |
| 207 | 202 | globalThis.gc(); | |
| 208 | - strictEqual(ref.deref(), undefined); | ||
| 203 | + assert.strictEqual(ref.deref(), undefined); | ||
| 209 | 204 | }); | |
| 210 | 205 | ||
| 211 | 206 | test('AbortSignal with a timeout is not collected while there is an active listener', async () => { | |
@@ -220,14 +215,14 @@ test('AbortSignal with a timeout is not collected while there is an active liste | |||
| 220 | 215 | ||
| 221 | 216 | await sleep(10); | |
| 222 | 217 | globalThis.gc(); | |
| 223 | - notStrictEqual(ref.deref(), undefined); | ||
| 224 | - ok(ref.deref() instanceof AbortSignal); | ||
| 218 | + assert.notStrictEqual(ref.deref(), undefined); | ||
| 219 | + assert.ok(ref.deref() instanceof AbortSignal); | ||
| 225 | 220 | ||
| 226 | 221 | ref.deref().removeEventListener('abort', handler); | |
| 227 | 222 | ||
| 228 | 223 | await sleep(10); | |
| 229 | 224 | globalThis.gc(); | |
| 230 | - strictEqual(ref.deref(), undefined); | ||
| 225 | + assert.strictEqual(ref.deref(), undefined); | ||
| 231 | 226 | }); | |
| 232 | 227 | ||
| 233 | 228 | test('Setting a long timeout should not keep the process open', () => { | |
@@ -237,18 +232,18 @@ test('Setting a long timeout should not keep the process open', () => { | |||
| 237 | 232 | test('AbortSignal.reason should default', () => { | |
| 238 | 233 | // Test AbortSignal.reason default | |
| 239 | 234 | const signal = AbortSignal.abort(); | |
| 240 | - ok(signal.reason instanceof DOMException); | ||
| 241 | - strictEqual(signal.reason.code, 20); | ||
| 235 | + assert.ok(signal.reason instanceof DOMException); | ||
| 236 | + assert.strictEqual(signal.reason.code, 20); | ||
| 242 | 237 | ||
| 243 | 238 | const ac = new AbortController(); | |
| 244 | 239 | ac.abort(); | |
| 245 | - ok(ac.signal.reason instanceof DOMException); | ||
| 246 | - strictEqual(ac.signal.reason.code, 20); | ||
| 240 | + assert.ok(ac.signal.reason instanceof DOMException); | ||
| 241 | + assert.strictEqual(ac.signal.reason.code, 20); | ||
| 247 | 242 | }); | |
| 248 | 243 | ||
| 249 | 244 | test('abortSignal.throwIfAborted() works as expected', () => { | |
| 250 | 245 | // Test abortSignal.throwIfAborted() | |
| 251 | - throws(() => AbortSignal.abort().throwIfAborted(), { | ||
| 246 | + assert.throws(() => AbortSignal.abort().throwIfAborted(), { | ||
| 252 | 247 | code: 20, | |
| 253 | 248 | name: 'AbortError', | |
| 254 | 249 | }); | |
@@ -262,7 +257,7 @@ test('abortSignal.throwIfAobrted() works as expected (2)', () => { | |||
| 262 | 257 | const originalDesc = Reflect.getOwnPropertyDescriptor(AbortSignal.prototype, 'aborted'); | |
| 263 | 258 | const actualReason = new Error(); | |
| 264 | 259 | Reflect.defineProperty(AbortSignal.prototype, 'aborted', { value: false }); | |
| 265 | - throws(() => AbortSignal.abort(actualReason).throwIfAborted(), actualReason); | ||
| 260 | + assert.throws(() => AbortSignal.abort(actualReason).throwIfAborted(), actualReason); | ||
| 266 | 261 | Reflect.defineProperty(AbortSignal.prototype, 'aborted', originalDesc); | |
| 267 | 262 | }); | |
| 268 | 263 | ||
@@ -271,6 +266,6 @@ test('abortSignal.throwIfAobrted() works as expected (3)', () => { | |||
| 271 | 266 | const actualReason = new Error(); | |
| 272 | 267 | const fakeExcuse = new Error(); | |
| 273 | 268 | Reflect.defineProperty(AbortSignal.prototype, 'reason', { value: fakeExcuse }); | |
| 274 | - throws(() => AbortSignal.abort(actualReason).throwIfAborted(), actualReason); | ||
| 269 | + assert.throws(() => AbortSignal.abort(actualReason).throwIfAborted(), actualReason); | ||
| 275 | 270 | Reflect.defineProperty(AbortSignal.prototype, 'reason', originalDesc); | |
| 276 | 271 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,9 @@ | |||
| 1 | 1 | // Flags: --expose-gc | |
| 2 | 2 | 'use strict'; | |
| 3 | 3 | ||
| 4 | - require('../common'); | ||
| 4 | + const common = require('../common'); | ||
| 5 | 5 | const { aborted } = require('util'); | |
| 6 | - const { | ||
| 7 | - match, | ||
| 8 | - rejects, | ||
| 9 | - strictEqual, | ||
| 10 | - } = require('assert'); | ||
| 6 | + const assert = require('assert'); | ||
| 11 | 7 | const { getEventListeners } = require('events'); | |
| 12 | 8 | const { inspect } = require('util'); | |
| 13 | 9 | ||
@@ -20,8 +16,8 @@ test('Aborted works when provided a resource', async () => { | |||
| 20 | 16 | const promise = aborted(ac.signal, {}); | |
| 21 | 17 | ac.abort(); | |
| 22 | 18 | await promise; | |
| 23 | - strictEqual(ac.signal.aborted, true); | ||
| 24 | - strictEqual(getEventListeners(ac.signal, 'abort').length, 0); | ||
| 19 | + assert.strictEqual(ac.signal.aborted, true); | ||
| 20 | + assert.strictEqual(getEventListeners(ac.signal, 'abort').length, 0); | ||
| 25 | 21 | }); | |
| 26 | 22 | ||
| 27 | 23 | test('Aborted with gc cleanup', async () => { | |
@@ -31,23 +27,23 @@ test('Aborted with gc cleanup', async () => { | |||
| 31 | 27 | const abortedPromise = aborted(ac.signal, {}); | |
| 32 | 28 | const { promise, resolve } = Promise.withResolvers(); | |
| 33 | 29 | ||
| 34 | - setImmediate(() => { | ||
| 30 | + setImmediate(common.mustCall(() => { | ||
| 35 | 31 | globalThis.gc(); | |
| 36 | 32 | ac.abort(); | |
| 37 | - strictEqual(ac.signal.aborted, true); | ||
| 38 | - strictEqual(getEventListeners(ac.signal, 'abort').length, 0); | ||
| 33 | + assert.strictEqual(ac.signal.aborted, true); | ||
| 34 | + assert.strictEqual(getEventListeners(ac.signal, 'abort').length, 0); | ||
| 39 | 35 | resolve(); | |
| 40 | - }); | ||
| 36 | + })); | ||
| 41 | 37 | ||
| 42 | 38 | await promise; | |
| 43 | 39 | ||
| 44 | 40 | // Ensure that the promise is still pending | |
| 45 | - match(inspect(abortedPromise), /<pending>/); | ||
| 41 | + assert.match(inspect(abortedPromise), /<pending>/); | ||
| 46 | 42 | }); | |
| 47 | 43 | ||
| 48 | 44 | test('Fails with error if not provided AbortSignal', async () => { | |
| 49 | 45 | await Promise.all([{}, null, undefined, Symbol(), [], 1, 0, 1n, true, false, 'a', () => {}].map((sig) => | |
| 50 | - rejects(aborted(sig, {}), { | ||
| 46 | + assert.rejects(aborted(sig, {}), { | ||
| 51 | 47 | code: 'ERR_INVALID_ARG_TYPE', | |
| 52 | 48 | }) | |
| 53 | 49 | )); | |
@@ -57,7 +53,7 @@ test('Fails if not provided a resource', async () => { | |||
| 57 | 53 | // Fails if not provided a resource | |
| 58 | 54 | const ac = new AbortController(); | |
| 59 | 55 | await Promise.all([null, undefined, 0, 1, 0n, 1n, Symbol(), '', 'a'].map((resource) => | |
| 60 | - rejects(aborted(ac.signal, resource), { | ||
| 56 | + assert.rejects(aborted(ac.signal, resource), { | ||
| 61 | 57 | code: 'ERR_INVALID_ARG_TYPE', | |
| 62 | 58 | }) | |
| 63 | 59 | )); | |
@@ -82,10 +78,10 @@ function lazySpawn() { | |||
| 82 | 78 | test('Does not hang forever', { skip: !lazySpawn() }, async () => { | |
| 83 | 79 | const { promise, resolve } = Promise.withResolvers(); | |
| 84 | 80 | const childProcess = spawn(process.execPath, ['--input-type=module']); | |
| 85 | - childProcess.on('exit', (code) => { | ||
| 86 | - strictEqual(code, 13); | ||
| 81 | + childProcess.on('exit', common.mustCall((code) => { | ||
| 82 | + assert.strictEqual(code, 13); | ||
| 87 | 83 | resolve(); | |
| 88 | - }); | ||
| 84 | + })); | ||
| 89 | 85 | childProcess.stdin.end(` | |
| 90 | 86 | import { aborted } from 'node:util'; | |
| 91 | 87 | await aborted(new AbortController().signal, {}); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments