js/src/tests/ecma_5/JSON/stringify-primitives.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.

     1 // Ported from dom/src/json/test/unit/test_encode_primitives.js
     3 // sanity
     4 var x = JSON.stringify({});
     5 assertEq(x, "{}");
     7 // booleans and null
     8 x = JSON.stringify(true);
     9 assertEq(x, "true");
    11 x = JSON.stringify(false);
    12 assertEq(x, "false");
    14 x = JSON.stringify(new Boolean(false));
    15 assertEq(x, "false");
    17 x = JSON.stringify(null);
    18 assertEq(x, "null");
    20 x = JSON.stringify(1234);
    21 assertEq(x, "1234");
    23 x = JSON.stringify(new Number(1234));
    24 assertEq(x, "1234");
    26 x = JSON.stringify("asdf");
    27 assertEq(x, '"asdf"');
    29 x = JSON.stringify(new String("asdf"));
    30 assertEq(x, '"asdf"');
    32 assertEq(JSON.stringify(undefined), undefined);
    33 assertEq(JSON.stringify(function(){}), undefined);
    34 assertEq(JSON.stringify(JSON.stringify), undefined);
    36 /******************************************************************************/
    38 if (typeof reportCompare === "function")
    39   reportCompare(true, true);
    41 print("Tests complete");

mercurial