Skip to content

Commit 9dbe9ad

Browse files
committed
[Robustness] test observably looks up exec on the object
1 parent 48896e8 commit 9dbe9ad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var forEach = require('for-each');
1313
var inspect = require('object-inspect');
1414
var isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
1515
var toLowerCase = callBound('String.prototype.toLowerCase');
16-
var $test = callBound('RegExp.prototype.test');
16+
var $exec = callBound('RegExp.prototype.exec');
1717
var objectToString = callBound('Object.prototype.toString');
1818

1919
module.exports = Test;
@@ -553,7 +553,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) {
553553
var passed = caught;
554554

555555
if (isRegExp(expected)) {
556-
passed = $test(expected, caught && caught.error);
556+
passed = $exec(expected, caught && caught.error) !== null;
557557
expected = String(expected);
558558
}
559559

@@ -610,7 +610,7 @@ Test.prototype.match = function match(string, regexp, msg, extra) {
610610
extra: extra
611611
});
612612
} else {
613-
var matches = $test(regexp, string);
613+
var matches = $exec(regexp, string) !== null;
614614
var message = defined(
615615
msg,
616616
'The input ' + (matches ? 'matched' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)
@@ -643,7 +643,7 @@ Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra)
643643
extra: extra
644644
});
645645
} else {
646-
var matches = $test(regexp, string);
646+
var matches = $exec(regexp, string) !== null;
647647
var message = defined(
648648
msg,
649649
'The input ' + (matches ? 'was expected to not match' : 'did not match') + ' the regular expression ' + inspect(regexp) + '. Input: ' + inspect(string)

0 commit comments

Comments
 (0)