From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/tests/non262/Array/at.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 js/src/tests/non262/Array/at.js (limited to 'js/src/tests/non262/Array/at.js') diff --git a/js/src/tests/non262/Array/at.js b/js/src/tests/non262/Array/at.js new file mode 100644 index 0000000000..e3227a3ec2 --- /dev/null +++ b/js/src/tests/non262/Array/at.js @@ -0,0 +1,39 @@ +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); -- cgit v1.2.3