diff --git a/lib/test.js b/lib/test.js index 652a4cdc..1be9494f 100644 --- a/lib/test.js +++ b/lib/test.js @@ -556,8 +556,12 @@ Test.prototype.match = function match(string, regexp, msg, extra) { } var matches = $test(regexp, string); + var message = defined( + msg, + 'The input ' + (matches ? 'matched' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string) + ); this._assert(matches, { - message: defined(msg, 'The input did not match the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)), + message: message, operator: 'match', actual: string, expected: regexp, @@ -573,8 +577,12 @@ Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra) throw new TypeError('The "string" argument must be of type string. Received type ' + typeof string + ' (' + inspect(string) + ')'); } var matches = $test(regexp, string); + var message = defined( + msg, + 'The input ' + (matches ? 'was expected to not match' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string) + ); this._assert(!matches, { - message: defined(msg, 'The input was expected to not match the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)), + message: message, operator: 'doesNotMatch', actual: string, expected: regexp, diff --git a/test/match.js b/test/match.js index 22d576d0..09ccd343 100644 --- a/test/match.js +++ b/test/match.js @@ -40,7 +40,7 @@ tap.test('match', function (tt) { ' at Test. ($TEST/match.js:$LINE:$COL)', ' [... stack stripped ...]', ' ...', - 'ok 5 The input did not match the regular expression /pass$/. Input: \'I will pass\'', + 'ok 5 The input matched the regular expression /pass$/. Input: \'I will pass\'', 'ok 6 "I will pass" matches /pass$/', '', '1..6',