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 isObject = require('../internals/is-object');
7 var DELEGATES_TO_EXEC = function () {
8 var execCalled = false;
10 re.exec = function () {
12 return /./.exec.apply(this, arguments);
14 return re.test('abc') === true && execCalled;
17 var nativeTest = /./.test;
19 $({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, {
20 test: function (str) {
21 if (typeof this.exec !== 'function') {
22 return nativeTest.call(this, str);
24 var result = this.exec(str);
25 if (result !== null && !isObject(result)) {
26 throw new Error('RegExp exec method returned something other than an Object or null');