js/src/tests/ecma_5/JSON/parse-syntax-errors-02.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_decode.js and
     2 // dom/src/json/test/unit/fail[1 to 34, minus 13].json
     4 testJSON('"Unterminated string literal', true);
     5 testJSON('["Unclosed array"', true);
     6 testJSON('{unquoted_key: "keys must be quoted"}', true);
     7 testJSON('["extra comma",]', true);
     8 testJSON('["double extra comma",,]', true);
     9 testJSON('[   , "<-- missing value"]', true);
    10 testJSON('["Comma after the close"],', true);
    11 testJSON('["Extra close"]]', true);
    12 testJSON('{"Extra comma": true,}', true);
    13 testJSON('{"Extra value after close": true} "misplaced quoted value"', true);
    14 testJSON('{"Illegal expression": 1 + 2}', true);
    15 testJSON('{"Illegal invocation": alert()}', true);
    16 testJSON('{"Numbers cannot be hex": 0x14}', true);
    17 testJSON('["Illegal backslash escape: \\x15"]', true);
    18 testJSON('[\\naked]', true);
    19 testJSON('["Illegal backslash escape: \\017"]', true);
    20 testJSON('{"Missing colon" null}', true);
    21 testJSON('{"Double colon":: null}', true);
    22 testJSON('{"Comma instead of colon", null}', true);
    23 testJSON('["Colon instead of comma": false]', true);
    24 testJSON('["Bad value", truth]', true);
    25 testJSON("['single quote']", true);
    26 testJSON('["	tab	character	in	string	"]', true);
    27 testJSON('["tab\\   character\\   in\\  string\\  "]', true);
    28 testJSON('["line\rbreak"]', true);
    29 testJSON('["line\nbreak"]', true);
    30 testJSON('["line\r\nbreak"]', true);
    31 testJSON('["line\\\rbreak"]', true);
    32 testJSON('["line\\\nbreak"]', true);
    33 testJSON('["line\\\r\nbreak"]', true);
    34 testJSON('[0e]', true);
    35 testJSON('[0e+]', true);
    36 testJSON('[0e+-1]', true);
    37 testJSON('{"Comma instead of closing brace": true,', true);
    38 testJSON('["mismatch"}', true);
    39 testJSON('0{', true);
    41 /******************************************************************************/
    43 if (typeof reportCompare === "function")
    44   reportCompare(true, true);
    46 print("Tests complete");

mercurial