js/src/jit-test/tests/basic/testInitSingletons.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 var x = [1,2.5,"three",true,false,null,[1,2,3],{a:0,b:1}];
michael@0 3 assertEq(String(x), "1,2.5,three,true,false,,1,2,3,[object Object]");
michael@0 4 assertEq(x.length, 8);
michael@0 5 assertEq(x[7].a, 0);
michael@0 6 assertEq(x[7].b, 1);
michael@0 7
michael@0 8 var y = {a:0,a:1,a:2};
michael@0 9 assertEq(y.a,2);
michael@0 10
michael@0 11 var z = {a:0,b:1,__proto__:{c:2,d:3}};
michael@0 12 assertEq(z.a,0);
michael@0 13 assertEq(z.b,1);
michael@0 14 assertEq(z.c,2);
michael@0 15 assertEq(z.d,3);
michael@0 16
michael@0 17 function foo() {
michael@0 18 var q = eval("[1,2,3]");
michael@0 19 var r = eval("[1,2,3]");
michael@0 20 assertEq(q === r, false);
michael@0 21 }
michael@0 22 foo();
michael@0 23
michael@0 24 var q = {0x4fffffff: 0, 0x7fffffff: 1, 0xffffffff: 2};
michael@0 25 assertEq(q[1342177279], 0);
michael@0 26 assertEq(q[2147483647], 1);
michael@0 27 assertEq(q[4294967295], 2);
michael@0 28
michael@0 29 try {
michael@0 30 [1,2,3,{a:0,b:1}].foo.bar;
michael@0 31 } catch (e) { assertEq(e.message.search("\.foo is undefined") != -1, true); }
michael@0 32
michael@0 33 var a = [1 + 1, 3 * 2, 6 - 5, 14 % 6, 15 / 5, 1 << 3,
michael@0 34 8 >> 2, 5 | 2, 5 ^ 3, ~3, -3,"a" + "b", !true, !false];
michael@0 35 assertEq(String(a), "2,6,1,2,3,8,2,7,6,-4,-3,ab,false,true");
michael@0 36 assertEq(a.length, 14);
michael@0 37
michael@0 38 var b = {
michael@0 39 a: 1 + 1,
michael@0 40 b: 3 * 2,
michael@0 41 c: 6 - 5,
michael@0 42 d: 14 % 6,
michael@0 43 e: 15 / 5,
michael@0 44 f: 1 << 3,
michael@0 45 g: 8 >> 2,
michael@0 46 h: 5 | 2,
michael@0 47 i: 5 ^ 3,
michael@0 48 j: ~3,
michael@0 49 k: -3,
michael@0 50 l: "a" + "b",
michael@0 51 m: !true,
michael@0 52 n: !false,
michael@0 53 }
michael@0 54
michael@0 55 var char = "a".charCodeAt(0);
michael@0 56 for (var i = 0; i < a.length; i++) {
michael@0 57 assertEq(b[String.fromCharCode(char)], a[i]);
michael@0 58 char++;
michael@0 59 }

mercurial