Skip to content

Commit cd0363b

Browse files
committed
add test coverage
Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
1 parent d31e4ae commit cd0363b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/harness/assert.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,19 @@ assert.throws(
8989
threw = false;
9090
try { assert.throws(() => { /* does not throw */ }); } catch { threw = true; }
9191
if (!threw) throw new Error('assert.throws must throw when fn does not throw');
92+
93+
// assert.match
94+
if (typeof assert.match !== 'function') {
95+
throw new Error('Expected assert.match to be a function');
96+
}
97+
assert.match('hello world', /hello/);
98+
assert.match('abc123', /^[a-z]+\d+$/);
99+
threw = false;
100+
try { assert.match('hello', /world/); } catch { threw = true; }
101+
if (!threw) throw new Error('assert.match("hello", /world/) must throw');
102+
threw = false;
103+
try { assert.match(123, /\d+/); } catch { threw = true; }
104+
if (!threw) throw new Error('assert.match must throw when input is not a string');
105+
threw = false;
106+
try { assert.match('hello', 'hello'); } catch { threw = true; }
107+
if (!threw) throw new Error('assert.match must throw when pattern is not a RegExp');

0 commit comments

Comments
 (0)