blob: 1d2379a0dbbf7c42a493d19fefc8ba5947f510e6 [file] [log] [blame]
//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py
//@ runNoFTL
function assert(testedValue, msg) {
if (!testedValue)
throw Error(msg);
}
// RegExp.prototype with overridden exec: Testing ES6 21.2.5.11: 19.b. Let z be ? RegExpExec(splitter, S).
(function () {
let accesses = [];
let origDescriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, "exec");
let origExec = origDescriptor.value;
let obj = /it/;
Object.defineProperty(RegExp.prototype, "exec", {
value: function(str) {
accesses.push("exec");
return origExec.call(this, str);
}
});
// The @@split slow path should only call the internal version of substr. Make sure
// that it's not calling the public version which can be overridden.
String.prototype.substr = function(start, length) {
throw Error("Should not call overridden substr");
}
// The @@split slow path should only call the internal version of includes. Make sure
// that it's not calling the public version which can be overridden.
String.prototype.includes = function(pattern) {
throw Error("Should not call overridden includes");
}
assert(accesses == "", "unexpected call to overridden props");
let result = RegExp.prototype[Symbol.split].call(obj, "splitme");
assert(accesses == "exec,exec,exec,exec,exec,exec", "Property accesses do not match expectation");
assert(result == "spl,me", "Unexpected result");
})();