summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/1659595.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/1659595.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/1659595.js')
-rw-r--r--js/src/jit-test/tests/1659595.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/1659595.js b/js/src/jit-test/tests/1659595.js
new file mode 100644
index 0000000000..663fa3017c
--- /dev/null
+++ b/js/src/jit-test/tests/1659595.js
@@ -0,0 +1,70 @@
+
+// Impliclitly converting regular numeric properties to computed numeric
+// properties in the parser means checking there's no semantic changes.
+
+let a = {
+ 0: 0,
+ 1n: 1n,
+
+ get 2() {
+ return 2;
+ },
+ set 2(o) {},
+
+ get 3n() {
+ return 3n;
+ },
+ set 3n(o) {}
+};
+
+assertEq(a[0], 0);
+assertEq(a[1n], 1n);
+assertEq(a[2], 2);
+assertEq(a[3n], 3n);
+
+function getterName(x) {
+ return Object.getOwnPropertyDescriptor(a, x).get.name
+}
+function setterName(x) {
+ return Object.getOwnPropertyDescriptor(a, x).set.name
+}
+
+assertEq(/get 2/.test(getterName(2)), true)
+assertEq(/get 3/.test(getterName(3n)), true)
+
+assertEq(/set 2/.test(setterName(2)), true)
+assertEq(/set 3/.test(setterName(3n)), true)
+
+let b = {
+ 0: 0,
+ [0]: 'dupe',
+ 1n: 1,
+ [1n]: 'dupe',
+ [2]: 2,
+ 2: 'dupe',
+ [3n]: 3,
+ 3n: 'dupe'
+};
+assertEq(b[0], 'dupe');
+assertEq(b[1n], 'dupe');
+assertEq(b[2], 'dupe');
+assertEq(b[3n], 'dupe');
+
+let c = {
+ 0: 0,
+ 0.0: 'dupe',
+};
+assertEq(c[0], 'dupe');
+
+let d = {
+ 0: 0,
+ '0': 'dupe',
+};
+assertEq(d[0], 'dupe');
+
+// Test numeric property destructuring.
+let {1: x} = {1: 1};
+let {1n: y} = {1n: 1n};
+
+assertEq(x, 1);
+assertEq(y, 1n);