summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_5/JSON/stringify-primitives.js
blob: 3f48638b8bf9491719f599ced1f10533e69b21ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// sanity
var x = JSON.stringify({});
assertEq(x, "{}");

// booleans and null
x = JSON.stringify(true);
assertEq(x, "true");

x = JSON.stringify(false);
assertEq(x, "false");

x = JSON.stringify(new Boolean(false));
assertEq(x, "false");

x = JSON.stringify(null);
assertEq(x, "null");

x = JSON.stringify(1234);
assertEq(x, "1234");

x = JSON.stringify(new Number(1234));
assertEq(x, "1234");

x = JSON.stringify("asdf");
assertEq(x, '"asdf"');

x = JSON.stringify(new String("asdf"));
assertEq(x, '"asdf"');

assertEq(JSON.stringify(undefined), undefined);
assertEq(JSON.stringify(function(){}), undefined);
assertEq(JSON.stringify(JSON.stringify), undefined);

/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("Tests complete");