js/src/tests/ecma_5/JSON/stringify-primitives.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:702447d5dacf
1 // Ported from dom/src/json/test/unit/test_encode_primitives.js
2
3 // sanity
4 var x = JSON.stringify({});
5 assertEq(x, "{}");
6
7 // booleans and null
8 x = JSON.stringify(true);
9 assertEq(x, "true");
10
11 x = JSON.stringify(false);
12 assertEq(x, "false");
13
14 x = JSON.stringify(new Boolean(false));
15 assertEq(x, "false");
16
17 x = JSON.stringify(null);
18 assertEq(x, "null");
19
20 x = JSON.stringify(1234);
21 assertEq(x, "1234");
22
23 x = JSON.stringify(new Number(1234));
24 assertEq(x, "1234");
25
26 x = JSON.stringify("asdf");
27 assertEq(x, '"asdf"');
28
29 x = JSON.stringify(new String("asdf"));
30 assertEq(x, '"asdf"');
31
32 assertEq(JSON.stringify(undefined), undefined);
33 assertEq(JSON.stringify(function(){}), undefined);
34 assertEq(JSON.stringify(JSON.stringify), undefined);
35
36 /******************************************************************************/
37
38 if (typeof reportCompare === "function")
39 reportCompare(true, true);
40
41 print("Tests complete");

mercurial