summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testInitSingletons.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/jit-test/tests/basic/testInitSingletons.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.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/jit-test/tests/basic/testInitSingletons.js')
-rw-r--r--js/src/jit-test/tests/basic/testInitSingletons.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/testInitSingletons.js b/js/src/jit-test/tests/basic/testInitSingletons.js
new file mode 100644
index 0000000000..82ca54c81c
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testInitSingletons.js
@@ -0,0 +1,61 @@
+
+var x = [1,2.5,"three",true,false,null,[1,2,3],{a:0,b:1}];
+assertEq(String(x), "1,2.5,three,true,false,,1,2,3,[object Object]");
+assertEq(x.length, 8);
+assertEq(x[7].a, 0);
+assertEq(x[7].b, 1);
+
+var y = {a:0,a:1,a:2};
+assertEq(y.a,2);
+
+var z = {a:0,b:1,__proto__:{c:2,d:3}};
+assertEq(z.a,0);
+assertEq(z.b,1);
+assertEq(z.c,2);
+assertEq(z.d,3);
+
+function foo() {
+ var q = eval("[1,2,3]");
+ var r = eval("[1,2,3]");
+ assertEq(q === r, false);
+}
+foo();
+
+var q = {0x4fffffff: 0, 0x7fffffff: 1, 0xffffffff: 2};
+assertEq(q[1342177279], 0);
+assertEq(q[2147483647], 1);
+assertEq(q[4294967295], 2);
+
+try {
+ [1,2,3,{a:0,b:1}].foo.bar;
+} catch (e) {
+ assertEq(/(.foo is|"bar" of) undefined/.test(e.message), true);
+}
+
+var a = [1 + 1, 3 * 2, 6 - 5, 14 % 6, 15 / 5, 1 << 3,
+ 8 >> 2, 5 | 2, 5 ^ 3, ~3, -3,"a" + "b", !true, !false];
+assertEq(String(a), "2,6,1,2,3,8,2,7,6,-4,-3,ab,false,true");
+assertEq(a.length, 14);
+
+var b = {
+ a: 1 + 1,
+ b: 3 * 2,
+ c: 6 - 5,
+ d: 14 % 6,
+ e: 15 / 5,
+ f: 1 << 3,
+ g: 8 >> 2,
+ h: 5 | 2,
+ i: 5 ^ 3,
+ j: ~3,
+ k: -3,
+ l: "a" + "b",
+ m: !true,
+ n: !false,
+}
+
+var char = "a".charCodeAt(0);
+for (var i = 0; i < a.length; i++) {
+ assertEq(b[String.fromCharCode(char)], a[i]);
+ char++;
+}