From d31e4aea24c749b5802d6c310445edf0ffc884b3 Mon Sep 17 00:00:00 2001 From: Balakrishna Avulapati Date: Thu, 16 Apr 2026 20:05:34 +0530 Subject: [PATCH 1/2] feat: add assert.match helper --- implementors/node/assert.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/implementors/node/assert.js b/implementors/node/assert.js index de9934c..c49a264 100644 --- a/implementors/node/assert.js +++ b/implementors/node/assert.js @@ -1,24 +1,22 @@ - import { ok, strictEqual, notStrictEqual, deepStrictEqual, throws, + match, } from "node:assert/strict"; -const assert = Object.assign( - (value, message) => ok(value, message), - { - ok: (value, message) => ok(value, message), - strictEqual: (actual, expected, message) => - strictEqual(actual, expected, message), - notStrictEqual: (actual, expected, message) => - notStrictEqual(actual, expected, message), - deepStrictEqual: (actual, expected, message) => - deepStrictEqual(actual, expected, message), - throws: (fn, error, message) => throws(fn, error, message), - }, -); +const assert = Object.assign((value, message) => ok(value, message), { + ok: (value, message) => ok(value, message), + strictEqual: (actual, expected, message) => + strictEqual(actual, expected, message), + notStrictEqual: (actual, expected, message) => + notStrictEqual(actual, expected, message), + deepStrictEqual: (actual, expected, message) => + deepStrictEqual(actual, expected, message), + throws: (fn, error, message) => throws(fn, error, message), + match: (string, regex, message) => match(string, regex, message), +}); Object.assign(globalThis, { assert }); From cd0363bb40461ef6377d5cba711bbab40062f584 Mon Sep 17 00:00:00 2001 From: Balakrishna Avulapati Date: Sun, 26 Apr 2026 19:11:15 +0530 Subject: [PATCH 2/2] add test coverage Signed-off-by: Balakrishna Avulapati --- tests/harness/assert.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/harness/assert.js b/tests/harness/assert.js index b6fcf20..65bf43c 100644 --- a/tests/harness/assert.js +++ b/tests/harness/assert.js @@ -89,3 +89,19 @@ assert.throws( threw = false; try { assert.throws(() => { /* does not throw */ }); } catch { threw = true; } if (!threw) throw new Error('assert.throws must throw when fn does not throw'); + +// assert.match +if (typeof assert.match !== 'function') { + throw new Error('Expected assert.match to be a function'); +} +assert.match('hello world', /hello/); +assert.match('abc123', /^[a-z]+\d+$/); +threw = false; +try { assert.match('hello', /world/); } catch { threw = true; } +if (!threw) throw new Error('assert.match("hello", /world/) must throw'); +threw = false; +try { assert.match(123, /\d+/); } catch { threw = true; } +if (!threw) throw new Error('assert.match must throw when input is not a string'); +threw = false; +try { assert.match('hello', 'hello'); } catch { threw = true; } +if (!threw) throw new Error('assert.match must throw when pattern is not a RegExp');