From 91f035e5975ad871977f3395664d3162444b3194 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 14 Aug 2025 11:51:13 +0200 Subject: [PATCH] assert: resolve TODO and rename function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/59451 Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Ulises Gascón Reviewed-By: Trivikram Kamat --- lib/assert.js | 10 ++++------ test/parallel/test-fs-promises.js | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index 3f9ef37542a..5ca0854f482 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -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', diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js index 796ad3224c4..a48c1f697a9 100644 --- a/test/parallel/test-fs-promises.js +++ b/test/parallel/test-fs-promises.js @@ -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());