summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Map/record-tuple.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/Map/record-tuple.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 '')
-rw-r--r--js/src/tests/non262/Map/record-tuple.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/non262/Map/record-tuple.js b/js/src/tests/non262/Map/record-tuple.js
new file mode 100644
index 0000000000..92c9d68414
--- /dev/null
+++ b/js/src/tests/non262/Map/record-tuple.js
@@ -0,0 +1,42 @@
+// |reftest| skip-if(!this.hasOwnProperty("Record"))
+
+function test(input, query, same) {
+ assertEq(set(input).has(query), same);
+ assertEq(new Map([[input, 1]]).has(query), same);
+ if (same) assertEq(new Map([[input, 1]]).get(query), 1);
+}
+function first(it) {
+ for (const v of it) return v;
+}
+function set(v) {
+ return new Set([v]);
+}
+
+
+test(#[0, 1], #[0, 1], true);
+test(#[0, 1], #[1, 0], false);
+
+test(#{x: 1}, #{x: 1}, true);
+test(#{x: 1}, #{y: 1}, false);
+test(#{x: 1}, #{x: 0}, false);
+test(#{x: 0, y: 1}, #{x: 0, y: 1}, true);
+test(#{x: 0, y: 1}, #{y: 1, x: 0}, true);
+test(#{x: 0, y: 1}, #{x: 1, y: 0}, false);
+test(#{x: 0, y: 1}, #{x: 0, y: 0}, false);
+
+test(#[NaN], #[NaN], true);
+test(#{x: NaN}, #{x: NaN}, true);
+test(#[+0], #[-0], true);
+test(#{x: +0}, #{x: -0}, true);
+assertEq(Object.is(first(set(#[+0]))[0], +0), true);
+assertEq(Object.is(first(set(#[-0]))[0], -0), true);
+assertEq(Object.is(first(set(#{x: +0})).x, +0), true);
+assertEq(Object.is(first(set(#{x: -0})).x, -0), true);
+
+// Test ropes.
+test(#["ab" + String.fromCodePoint(67)], #["ab" + String.fromCodePoint(67)], true);
+test(#{ x: "ab" + String.fromCodePoint(67) }, #{ x: "ab" + String.fromCodePoint(67) }, true);
+test(#["ab" + String.fromCodePoint(67)], #["ab" + String.fromCodePoint(68)], false);
+test(#{ x: "ab" + String.fromCodePoint(67) }, #{ x: "ab" + String.fromCodePoint(68) }, false);
+
+if (typeof reportCompare === "function") reportCompare(0, 0);