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