Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Ported from dom/src/json/test/unit/test_decode_primitives.js
3 var x;
5 // check an empty object, just for sanity
6 var emptyObject = "{}";
7 x = JSON.parse(emptyObject);
8 assertEq(typeof x, "object");
9 assertEq(x instanceof Object, true);
11 x = JSON.parse(emptyObject);
12 assertEq(typeof x, "object");
14 // booleans and null
15 x = JSON.parse("true");
16 assertEq(x, true);
18 x = JSON.parse("true ");
19 assertEq(x, true);
21 x = JSON.parse("false");
22 assertEq(x, false);
24 x = JSON.parse(" null ");
25 assertEq(x, null);
27 // numbers
28 x = JSON.parse("1234567890");
29 assertEq(x, 1234567890);
31 x = JSON.parse("-9876.543210");
32 assertEq(x, -9876.543210);
34 x = JSON.parse("0.123456789e-12");
35 assertEq(x, 0.123456789e-12);
37 x = JSON.parse("1.234567890E+34");
38 assertEq(x, 1.234567890E+34);
40 x = JSON.parse(" 23456789012E66 \r\r\r\r \n\n\n\n ");
41 assertEq(x, 23456789012E66);
43 // strings
44 x = JSON.parse('"foo"');
45 assertEq(x, "foo");
47 x = JSON.parse('"\\r\\n"');
48 assertEq(x, "\r\n");
50 x = JSON.parse(' "\\uabcd\uef4A"');
51 assertEq(x, "\uabcd\uef4A");
53 x = JSON.parse('"\\uabcd" ');
54 assertEq(x, "\uabcd");
56 x = JSON.parse('"\\f"');
57 assertEq(x, "\f");
59 /******************************************************************************/
61 if (typeof reportCompare === "function")
62 reportCompare(true, true);
64 print("Tests complete");