assert: resolve TODO and rename function

PR-URL: https://github.com/nodejs/node/pull/59451
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Antoine du Hamel 2025-08-14 11:51:13 +02:00 committed by GitHub
parent 6626b16dd8
commit 91f035e597
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 7 deletions

View File

@ -83,7 +83,7 @@ function lazyLoadComparison() {
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.
const assert = module.exports = ok;
module.exports = assert;
const NO_EXCEPTION_SENTINEL = {};
@ -186,8 +186,8 @@ assert.AssertionError = AssertionError;
* @param {...any} args
* @returns {void}
*/
function ok(...args) {
innerOk(ok, args.length, ...args);
function assert(...args) {
innerOk(assert, args.length, ...args);
}
/**
@ -890,10 +890,8 @@ function strict(...args) {
innerOk(strict, args.length, ...args);
}
// TODO(aduh95): take `ok` from `Assert.prototype` instead of a self-ref in a next major.
assert.ok = assert;
ArrayPrototypeForEach([
'fail', 'equal', 'notEqual', 'deepEqual', 'notDeepEqual',
'ok', 'fail', 'equal', 'notEqual', 'deepEqual', 'notDeepEqual',
'deepStrictEqual', 'notDeepStrictEqual', 'strictEqual',
'notStrictEqual', 'partialDeepStrictEqual', 'match', 'doesNotMatch',
'throws', 'rejects', 'doesNotThrow', 'doesNotReject', 'ifError',

View File

@ -58,7 +58,7 @@ assert.strictEqual(
code: 'ENOENT',
name: 'Error',
message: /^ENOENT: no such file or directory, access/,
stack: /at async ok\.rejects/
stack: /at async assert\.rejects/
}
).then(common.mustCall());