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/Array/at.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.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/Array/at.js')
-rw-r--r-- | js/src/tests/non262/Array/at.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/tests/non262/Array/at.js b/js/src/tests/non262/Array/at.js new file mode 100644 index 0000000000..0e7ca9cb14 --- /dev/null +++ b/js/src/tests/non262/Array/at.js @@ -0,0 +1,41 @@ +// |reftest| skip-if(!Array.prototype.at) + +function basic() { + assertEq([0].at(0), 0); + assertEq([0].at(-1), 0); + + assertEq([].at(0), undefined); + assertEq([].at(-1), undefined); + assertEq([].at(1), undefined); + + assertEq([0, 1].at(0), 0); + assertEq([0, 1].at(1), 1); + assertEq([0, 1].at(-2), 0); + assertEq([0, 1].at(-1), 1); + + assertEq([0, 1].at(2), undefined); + assertEq([0, 1].at(-3), undefined); + assertEq([0, 1].at(-4), undefined); + assertEq([0, 1].at(Infinity), undefined); + assertEq([0, 1].at(-Infinity), undefined); + assertEq([0, 1].at(NaN), 0); // ToInteger(NaN) = 0 +} + +function obj() { + var o = {length: 0, [0]: "a", at: Array.prototype.at}; + + assertEq(o.at(0), undefined); + assertEq(o.at(-1), undefined); + + o.length = 1; + assertEq(o.at(0), "a"); + assertEq(o.at(-1), "a"); + assertEq(o.at(1), undefined); + assertEq(o.at(-2), undefined); +} + +basic(); +obj(); + +if (typeof reportCompare === "function") + reportCompare(true, true); |