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.

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

mercurial