diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/non262/RegExp/search-trace.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/RegExp/search-trace.js')
-rw-r--r-- | js/src/tests/non262/RegExp/search-trace.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/js/src/tests/non262/RegExp/search-trace.js b/js/src/tests/non262/RegExp/search-trace.js new file mode 100644 index 0000000000..fc6bee754c --- /dev/null +++ b/js/src/tests/non262/RegExp/search-trace.js @@ -0,0 +1,78 @@ +var BUGNUMBER = 887016; +var summary = "Trace RegExp.prototype[@@search] behavior."; + +print(BUGNUMBER + ": " + summary); + +var n; +var log; +var target; + +var execResult; +var lastIndexResult; +var lastIndexExpected; + +function P(index) { + return new Proxy({ index }, { + get(that, name) { + log += "get:result[" + name + "],"; + return that[name]; + } + }); +} + +var myRegExp = { + get lastIndex() { + log += "get:lastIndex,"; + return lastIndexResult[n]; + }, + set lastIndex(v) { + log += "set:lastIndex,"; + assertEq(v, lastIndexExpected[n]); + }, + get exec() { + log += "get:exec,"; + return function(S) { + log += "call:exec,"; + assertEq(S, target); + return execResult[n++]; + }; + }, +}; + +function reset() { + n = 0; + log = ""; + target = "abcAbcABC"; +} + +// Trace hit. +reset(); +execResult = [ P(16) ]; +lastIndexResult = [ 10, , ]; +lastIndexExpected = [ 0, 10 ]; +var ret = RegExp.prototype[Symbol.search].call(myRegExp, target); +assertEq(ret, 16); +assertEq(log, + "get:lastIndex," + + "set:lastIndex," + + "get:exec,call:exec," + + "get:lastIndex," + + "set:lastIndex," + + "get:result[index],"); + +// Trace not hit. +reset(); +execResult = [ null ]; +lastIndexResult = [ 10, , ]; +lastIndexExpected = [ 0, 10 ]; +ret = RegExp.prototype[Symbol.search].call(myRegExp, target); +assertEq(ret, -1); +assertEq(log, + "get:lastIndex," + + "set:lastIndex," + + "get:exec,call:exec," + + "get:lastIndex," + + "set:lastIndex,"); + +if (typeof reportCompare === "function") + reportCompare(true, true); |