Skip to content

Commit 2db8d3e

Browse files
committed
add coverage for object matcher and validator function of assert.throws
Reported on #42 Signed-off-by: Balakrishna Avulapati <ba@bavulapati.com>
1 parent 509ba00 commit 2db8d3e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/harness/assert.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ if (typeof assert.throws !== 'function') {
7878
}
7979
assert.throws(() => { throw new Error('oops'); }, /oops/);
8080
assert.throws(() => { throw new TypeError('bad'); }, TypeError);
81+
assert.throws(
82+
() => { const err = new Error('match me'); err.code = 'ERR_TEST'; throw err; },
83+
{ code: 'ERR_TEST', message: 'match me' },
84+
);
85+
assert.throws(
86+
() => { throw new RangeError('validate me'); },
87+
(err) => err instanceof RangeError && err.message === 'validate me',
88+
);
8189
threw = false;
8290
try { assert.throws(() => { /* does not throw */ }); } catch { threw = true; }
8391
if (!threw) throw new Error('assert.throws must throw when fn does not throw');

0 commit comments

Comments
 (0)