Skip to content

Commit

Permalink
test: improve test-assert
Browse files Browse the repository at this point in the history
Add RegExp to check assert throws the expected AssertionErrors.

For the one with multiple flags is ok to hardcode the flags since the
spec indicates the ordering will always be `gim`:

Refs: http://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags
PR-URL: nodejs#10916
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
richnologies authored and italoacasas committed Jan 25, 2017
1 parent 835ed8b commit 46b2583
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,26 @@ assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/g, /a/g));
assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/i, /a/i));
assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/m, /a/m));
assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/igm, /a/igm));
assert.throws(makeBlock(a.deepStrictEqual, /ab/, /a/));
assert.throws(makeBlock(a.deepStrictEqual, /a/g, /a/));
assert.throws(makeBlock(a.deepStrictEqual, /a/i, /a/));
assert.throws(makeBlock(a.deepStrictEqual, /a/m, /a/));
assert.throws(makeBlock(a.deepStrictEqual, /a/igm, /a/im));
assert.throws(
makeBlock(a.deepStrictEqual, /ab/, /a/),
/^AssertionError: \/ab\/ deepStrictEqual \/a\/$/
);
assert.throws(
makeBlock(a.deepStrictEqual, /a/g, /a/),
/^AssertionError: \/a\/g deepStrictEqual \/a\/$/
);
assert.throws(
makeBlock(a.deepStrictEqual, /a/i, /a/),
/^AssertionError: \/a\/i deepStrictEqual \/a\/$/
);
assert.throws(
makeBlock(a.deepStrictEqual, /a/m, /a/),
/^AssertionError: \/a\/m deepStrictEqual \/a\/$/
);
assert.throws(
makeBlock(a.deepStrictEqual, /a/igm, /a/im),
/^AssertionError: \/a\/gim deepStrictEqual \/a\/im$/
);

{
const re1 = /a/;
Expand Down

0 comments on commit 46b2583

Please sign in to comment.