js/src/tests/ecma_5/JSON/parse-syntax-errors-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/JSON/parse-syntax-errors-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +// Ported from dom/src/json/test/unit/test_decode.js and
     1.5 +// dom/src/json/test/unit/fail[1 to 34, minus 13].json
     1.6 +
     1.7 +testJSON('"Unterminated string literal', true);
     1.8 +testJSON('["Unclosed array"', true);
     1.9 +testJSON('{unquoted_key: "keys must be quoted"}', true);
    1.10 +testJSON('["extra comma",]', true);
    1.11 +testJSON('["double extra comma",,]', true);
    1.12 +testJSON('[   , "<-- missing value"]', true);
    1.13 +testJSON('["Comma after the close"],', true);
    1.14 +testJSON('["Extra close"]]', true);
    1.15 +testJSON('{"Extra comma": true,}', true);
    1.16 +testJSON('{"Extra value after close": true} "misplaced quoted value"', true);
    1.17 +testJSON('{"Illegal expression": 1 + 2}', true);
    1.18 +testJSON('{"Illegal invocation": alert()}', true);
    1.19 +testJSON('{"Numbers cannot be hex": 0x14}', true);
    1.20 +testJSON('["Illegal backslash escape: \\x15"]', true);
    1.21 +testJSON('[\\naked]', true);
    1.22 +testJSON('["Illegal backslash escape: \\017"]', true);
    1.23 +testJSON('{"Missing colon" null}', true);
    1.24 +testJSON('{"Double colon":: null}', true);
    1.25 +testJSON('{"Comma instead of colon", null}', true);
    1.26 +testJSON('["Colon instead of comma": false]', true);
    1.27 +testJSON('["Bad value", truth]', true);
    1.28 +testJSON("['single quote']", true);
    1.29 +testJSON('["	tab	character	in	string	"]', true);
    1.30 +testJSON('["tab\\   character\\   in\\  string\\  "]', true);
    1.31 +testJSON('["line\rbreak"]', true);
    1.32 +testJSON('["line\nbreak"]', true);
    1.33 +testJSON('["line\r\nbreak"]', true);
    1.34 +testJSON('["line\\\rbreak"]', true);
    1.35 +testJSON('["line\\\nbreak"]', true);
    1.36 +testJSON('["line\\\r\nbreak"]', true);
    1.37 +testJSON('[0e]', true);
    1.38 +testJSON('[0e+]', true);
    1.39 +testJSON('[0e+-1]', true);
    1.40 +testJSON('{"Comma instead of closing brace": true,', true);
    1.41 +testJSON('["mismatch"}', true);
    1.42 +testJSON('0{', true);
    1.43 +
    1.44 +/******************************************************************************/
    1.45 +
    1.46 +if (typeof reportCompare === "function")
    1.47 +  reportCompare(true, true);
    1.48 +
    1.49 +print("Tests complete");

mercurial