Skip to content

Commit

Permalink
test: add message verification on assert.throws
Browse files Browse the repository at this point in the history
Add regular expression for error message validation to instances of
assert.throws() in test-assert.js.

PR-URL: #10890
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
tmeisenh authored and italoacasas committed Jan 30, 2017
1 parent 5ce2ac8 commit c4f1694
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ assert.doesNotThrow(makeBlock(a.deepEqual, /a/g, /a/g));
assert.doesNotThrow(makeBlock(a.deepEqual, /a/i, /a/i));
assert.doesNotThrow(makeBlock(a.deepEqual, /a/m, /a/m));
assert.doesNotThrow(makeBlock(a.deepEqual, /a/igm, /a/igm));
assert.throws(makeBlock(a.deepEqual, /ab/, /a/));
assert.throws(makeBlock(a.deepEqual, /a/g, /a/));
assert.throws(makeBlock(a.deepEqual, /a/i, /a/));
assert.throws(makeBlock(a.deepEqual, /a/m, /a/));
assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im));
assert.throws(makeBlock(a.deepEqual, /ab/, /a/),
/^AssertionError: \/ab\/ deepEqual \/a\/$/);
assert.throws(makeBlock(a.deepEqual, /a/g, /a/),
/^AssertionError: \/a\/g deepEqual \/a\/$/);
assert.throws(makeBlock(a.deepEqual, /a/i, /a/),
/^AssertionError: \/a\/i deepEqual \/a\/$/);
assert.throws(makeBlock(a.deepEqual, /a/m, /a/),
/^AssertionError: \/a\/m deepEqual \/a\/$/);
assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im),
/^AssertionError: \/a\/gim deepEqual \/a\/im$/);

{
const re1 = /a/;
Expand Down

0 comments on commit c4f1694

Please sign in to comment.