diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js b/js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js new file mode 100644 index 0000000000..2c672ef1ce --- /dev/null +++ b/js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty("Tuple")) +/* +8.2.3.28 Tuple.prototype.toReversed ( ) +When the toReversed method is called, the following steps are taken: + +1. Let T be ? thisTupleValue(this value). +2. Let oldList be a new List containing the elements of T.[[Sequence]]. +3. Let newList be a new empty List. +4. Repeat, while oldList is not empty, +a. Remove the last element from oldList, and let E be the value of the element. +b. Append E to the end of List newList. +5. Return a new Tuple value whose [[Sequence]] is newList. +*/ +/* Step 1 */ +/* toReversed() should throw on a non-Tuple */ +let method = Tuple.prototype.toReversed; +assertEq(method.call(#[1,2,3,4,5,6]), #[6,5,4,3,2,1]); +assertEq(method.call(Object(#[1,2,3,4,5,6])), #[6,5,4,3,2,1]); +assertThrowsInstanceOf(() => method.call("monkeys"), TypeError, + "value of TupleObject must be a Tuple"); + +assertEq(#[].toReversed(), #[]); +assertEq(#[1].toReversed(), #[1]); + +/* Test that length is still handled correctly if it's overridden */ +Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } }) +assertEq(#[1,2,3,4,5].toReversed(), #[5,4,3,2,1]); + +reportCompare(0, 0); |