2 // TODO: Remove from `core-js@4` since it's moved to entry points
3 require('../modules/es.regexp.exec');
4 var $ = require('../internals/export');
5 var global = require('../internals/global');
6 var call = require('../internals/function-call');
7 var uncurryThis = require('../internals/function-uncurry-this');
8 var isCallable = require('../internals/is-callable');
9 var isObject = require('../internals/is-object');
11 var DELEGATES_TO_EXEC = function () {
12 var execCalled = false;
14 re.exec = function () {
16 return /./.exec.apply(this, arguments);
18 return re.test('abc') === true && execCalled;
21 var Error = global.Error;
22 var un$Test = uncurryThis(/./.test);
24 // `RegExp.prototype.test` method
25 // https://tc39.es/ecma262/#sec-regexp.prototype.test
26 $({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, {
27 test: function (str) {
29 if (!isCallable(exec)) return un$Test(this, str);
30 var result = call(exec, this, str);
31 if (result !== null && !isObject(result)) {
32 throw new Error('RegExp exec method returned something other than an Object or null');