diff --git a/lib/test.js b/lib/test.js index 8297580c..188e0e9b 100644 --- a/lib/test.js +++ b/lib/test.js @@ -18,7 +18,7 @@ var every = require('array.prototype.every'); var isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); var toLowerCase = callBound('String.prototype.toLowerCase'); var isProto = callBound('Object.prototype.isPrototypeOf'); -var $test = callBound('RegExp.prototype.test'); +var $exec = callBound('RegExp.prototype.exec'); var objectToString = callBound('Object.prototype.toString'); var $split = callBound('String.prototype.split'); var $replace = callBound('String.prototype.replace'); @@ -654,7 +654,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) { passed = expected.call({}, caught.error) === true; } } else if (isRegExp(expected)) { - passed = $test(expected, caught.error); + passed = $exec(expected, caught.error) !== null; expected = inspect(expected); } else if (expected && typeof expected === 'object') { // Handle validation objects. var keys = objectKeys(expected); @@ -665,7 +665,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) { throw new TypeError('`throws` validation object must not be empty'); } passed = every(keys, function (key) { - if (typeof caught.error[key] === 'string' && isRegExp(expected[key]) && $test(expected[key], caught.error[key])) { + if (typeof caught.error[key] === 'string' && isRegExp(expected[key]) && $exec(expected[key], caught.error[key]) !== null) { return true; } if (key in caught.error && deepEqual(caught.error[key], expected[key], { strict: true })) { @@ -725,7 +725,7 @@ Test.prototype.match = function match(string, regexp, msg, extra) { extra: extra }); } else { - var matches = $test(regexp, string); + var matches = $exec(regexp, string) !== null; var message = defined( msg, 'The input ' + (matches ? 'matched' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string) @@ -758,7 +758,7 @@ Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra) extra: extra }); } else { - var matches = $test(regexp, string); + var matches = $exec(regexp, string) !== null; var message = defined( msg, 'The input ' + (matches ? 'was expected to not match' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)