mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 14:22:28 +00:00
Audit every single JSON test
This commit is contained in:
parent
7965ed0232
commit
3f3e7e92d7
17 changed files with 473 additions and 285 deletions
|
@ -1,6 +1,6 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass1.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[
|
||||
"JSON Test Pattern pass1",
|
||||
{"object with 1 member":[ "array with 1 element"] },
|
||||
|
@ -63,14 +63,13 @@ assert(pcall(DecodeJson, [[
|
|||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass2.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Not too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
|
||||
]]))
|
||||
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass3.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
{
|
||||
"JSON Test Pattern pass3": {
|
||||
"The outermost value": "must be an object or array.",
|
||||
|
@ -80,18 +79,20 @@ assert(pcall(DecodeJson, [[
|
|||
|
||||
]]))
|
||||
|
||||
|
||||
-- json.org says these should fail, but many parsers,
|
||||
-- including python's json.load allow the following
|
||||
|
||||
-- [jart] our behavior is consistent with v8
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail1.json (actually passes)
|
||||
assert(pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
"A JSON payload should be an object or array, not a string."
|
||||
]]))
|
||||
|
||||
-- [jart] this deviates from json.org
|
||||
-- we permit depth up to 128
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail18.json (actually passes)
|
||||
assert(pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
|
||||
]]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue