summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/enumeration.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Tuple/enumeration.js
parentInitial commit. (diff)
downloadfirefox-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 'js/src/tests/non262/Tuple/enumeration.js')
-rw-r--r--js/src/tests/non262/Tuple/enumeration.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/enumeration.js b/js/src/tests/non262/Tuple/enumeration.js
new file mode 100644
index 0000000000..834c919e8e
--- /dev/null
+++ b/js/src/tests/non262/Tuple/enumeration.js
@@ -0,0 +1,48 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var tup = #[1, 2, 3];
+
+var keys = Object.keys(tup);
+assertEq(keys.length, 3);
+assertEq(keys[0], "0");
+assertEq(keys[1], "1");
+assertEq(keys[2], "2");
+
+var values = Object.values(tup);
+assertEq(values.length, 3);
+assertEq(values[0], 1);
+assertEq(values[1], 2);
+assertEq(values[2], 3);
+
+var entries = Object.entries(tup);
+assertEq(entries.length, 3);
+assertEq(entries[0][0], "0");
+assertEq(entries[0][1], 1);
+assertEq(entries[1][0], "1");
+assertEq(entries[1][1], 2);
+assertEq(entries[2][0], "2");
+assertEq(entries[2][1], 3);
+
+var ownKeys = Reflect.ownKeys(Object(tup));
+assertEq(ownKeys.length, 3);
+assertEq(ownKeys[0], "0");
+assertEq(ownKeys[1], "1");
+assertEq(ownKeys[2], "2");
+
+var spreadKeys = Object.keys({ ...tup });
+assertEq(spreadKeys.length, 3);
+assertEq(spreadKeys[0], "0");
+assertEq(spreadKeys[1], "1");
+assertEq(spreadKeys[2], "2");
+
+var i = 0;
+for (var key in tup) {
+ switch (i++) {
+ case 0: assertEq(key, "0"); break;
+ case 1: assertEq(key, "1"); break;
+ case 2: assertEq(key, "2"); break;
+ default: assertUnreachable();
+ }
+}
+
+if (typeof reportCompare === "function") reportCompare(0, 0);