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/jit-test/tests/basic/testInitSingletons.js | 61 +++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 js/src/jit-test/tests/basic/testInitSingletons.js (limited to 'js/src/jit-test/tests/basic/testInitSingletons.js') 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++; +} -- cgit v1.2.3