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 }); 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');