mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Further improve JSON serialization
This commit is contained in:
parent
4814b6bdf8
commit
6ee18986e4
20 changed files with 868 additions and 687 deletions
|
@ -61,6 +61,8 @@ assert(EncodeJson(0) == "0")
|
|||
assert(EncodeJson(3.14) == "3.14")
|
||||
assert(EncodeJson({2, 1}) == "[2,1]")
|
||||
|
||||
assert(EncodeLua(" [\"new\nline\"] ") == "\" [\\\"new\\nline\\\"] \"")
|
||||
|
||||
-- EncodeLua() permits serialization of cyclic data structures
|
||||
x = {2, 1}
|
||||
x[3] = x
|
||||
|
@ -78,7 +80,13 @@ x = {2, 1}
|
|||
x[3] = x
|
||||
json, err = EncodeJson(x)
|
||||
assert(not json)
|
||||
assert(err == "serialization failed")
|
||||
assert(err == "won't serialize cyclic lua table")
|
||||
|
||||
-- pass the parser to itself lool
|
||||
json, err = EncodeJson(EncodeJson)
|
||||
assert(not json)
|
||||
print(err)
|
||||
assert(err == "unsupported lua type")
|
||||
|
||||
-- EncodeJson() sorts table entries
|
||||
-- JSON always requires quotes around key names
|
||||
|
|
|
@ -13,58 +13,104 @@
|
|||
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
assert(EncodeLua(DecodeJson[[ ]]) == 'nil')
|
||||
assert(EncodeLua(DecodeJson[[ 0 ]]) == '0' )
|
||||
assert(EncodeLua(DecodeJson[[ [1] ]]) == '{1}')
|
||||
assert(EncodeLua(DecodeJson[[ 2.3 ]]) == '2.3')
|
||||
assert(EncodeLua(DecodeJson[[ [1,3,2] ]]) == '{1, 3, 2}')
|
||||
-- assert(EncodeLua(DecodeJson[[ {1: 2, 3: 4} ]]) == '{[1]=2, [3]=4}')
|
||||
assert(EncodeLua(DecodeJson[[ {"foo": 2, "bar": 4} ]]) == '{bar=4, foo=2}')
|
||||
assert(EncodeLua(DecodeJson[[ null ]]) == 'nil')
|
||||
assert(EncodeLua(DecodeJson[[ -123 ]]) == '-123')
|
||||
assert(EncodeLua(DecodeJson[[ 1e6 ]]) == '1000000.')
|
||||
assert(EncodeLua(DecodeJson[[ 1.e-6 ]]) == '0.000001')
|
||||
assert(EncodeLua(DecodeJson[[ 1e-06 ]]) == '0.000001')
|
||||
assert(EncodeLua(DecodeJson[[ 9.123e6 ]]) == '9123000.')
|
||||
assert(EncodeLua(DecodeJson[[ [{"heh": [1,3,2]}] ]]) == '{{heh={1, 3, 2}}}')
|
||||
assert(EncodeLua(DecodeJson[[ 3.14159 ]]) == '3.14159')
|
||||
-- assert(EncodeLua(DecodeJson[[ {3=4} ]]) == '{[3]=4}')
|
||||
assert(EncodeLua(DecodeJson[[ 1e-12 ]]) == '1e-12')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 0 ]])) == '0' )
|
||||
assert(EncodeLua(assert(DecodeJson[[ [1] ]])) == '{1}')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 2.3 ]])) == '2.3')
|
||||
assert(EncodeLua(assert(DecodeJson[[ [1,3,2] ]])) == '{1, 3, 2}')
|
||||
-- assert(EncodeLua(assert(DecodeJson[[ {1: 2, 3: 4} ]])) == '{[1]=2, [3]=4}')
|
||||
assert(EncodeLua(assert(DecodeJson[[ {"foo": 2, "bar": 4} ]])) == '{bar=4, foo=2}')
|
||||
assert(EncodeLua(assert(DecodeJson[[ -123 ]])) == '-123')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 1e6 ]])) == '1000000.')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 1.e-6 ]])) == '0.000001')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 1e-06 ]])) == '0.000001')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 9.123e6 ]])) == '9123000.')
|
||||
assert(EncodeLua(assert(DecodeJson[[ [{"heh": [1,3,2]}] ]])) == '{{heh={1, 3, 2}}}')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 3.14159 ]])) == '3.14159')
|
||||
-- assert(EncodeLua(assert(DecodeJson[[ {3=4} ]])) == '{[3]=4}')
|
||||
assert(EncodeLua(assert(DecodeJson[[ 1e-12 ]])) == '1e-12')
|
||||
|
||||
assert(EncodeJson(DecodeJson[[ 1e-12 ]]) == '1e-12')
|
||||
assert(EncodeJson(DecodeJson[[ true ]]) == 'true')
|
||||
assert(EncodeJson(DecodeJson[[ false ]]) == 'false')
|
||||
assert(EncodeJson(DecodeJson[[ null ]]) == 'null')
|
||||
assert(EncodeJson(DecodeJson[[ [] ]]) == '[]')
|
||||
assert(EncodeJson(DecodeJson[[ {} ]]) == '{}')
|
||||
assert(EncodeJson(assert(DecodeJson[[ 1e-12 ]])) == '1e-12')
|
||||
assert(EncodeJson(assert(DecodeJson[[ true ]])) == 'true')
|
||||
assert(EncodeJson(assert(DecodeJson[[ [] ]])) == '[]')
|
||||
assert(EncodeJson(assert(DecodeJson[[ {} ]])) == '{}')
|
||||
|
||||
assert(DecodeJson[["\f"]] == '\f') -- c0
|
||||
assert(DecodeJson[["\t"]] == '\t') -- c0
|
||||
assert(DecodeJson[["\n"]] == '\n') -- c0
|
||||
assert(DecodeJson[["\r"]] == '\r') -- c0
|
||||
assert(DecodeJson[["\\"]] == '\\') -- c0
|
||||
assert(DecodeJson[["\""]] == '\"') -- c0
|
||||
assert(DecodeJson[["\u0100"]] == 'Ā') -- latin-1
|
||||
assert(DecodeJson[["\ud800\udf30\ud800\udf30"]] == '𐌰𐌰') -- utf-16 astral planes gothic
|
||||
assert(DecodeJson[["\uD800"]] == '\\uD800') -- utf-16 invalid (keep utf-8 well-formed)
|
||||
assert(assert(DecodeJson[["\f"]]) == '\f') -- c0
|
||||
assert(assert(DecodeJson[["\t"]]) == '\t') -- c0
|
||||
assert(assert(DecodeJson[["\n"]]) == '\n') -- c0
|
||||
assert(assert(DecodeJson[["\r"]]) == '\r') -- c0
|
||||
assert(assert(DecodeJson[["\\"]]) == '\\') -- c0
|
||||
assert(assert(DecodeJson[["\""]]) == '\"') -- c0
|
||||
assert(assert(DecodeJson[["\u0100"]]) == 'Ā') -- latin-1
|
||||
assert(assert(DecodeJson[["\ud800\udf30\ud800\udf30"]]) == '𐌰𐌰') -- utf-16 astral planes gothic
|
||||
assert(assert(DecodeJson[["\uD800"]]) == '\\uD800') -- utf-16 invalid (keep utf-8 well-formed)
|
||||
|
||||
assert(EncodeJson(DecodeJson[[ -9223372036854775808 ]]) == '-9223372036854775808') -- minimum 64-bit integer
|
||||
assert(EncodeJson(DecodeJson[[ 9223372036854775807 ]]) == '9223372036854775807') -- maximum 64-bit integer
|
||||
assert(EncodeJson(DecodeJson[[ 9223372036854775808 ]]) == '9223372036854776000') -- switches to double due to integer overflow
|
||||
assert(EncodeJson(DecodeJson[[ -9223372036854775809 ]]) == '-9223372036854776000') -- switches to double due to integer underflow
|
||||
assert(EncodeJson(DecodeJson[[ 9223372036854775807.0 ]]) == '9223372036854776000') -- switches to double due to period mark
|
||||
assert(EncodeJson(DecodeJson[[ 2.7182818284590452354 ]]) == '2.718281828459045') -- euler constant w/ 17 digit precision
|
||||
assert( EncodeLua(DecodeJson[[ 2.7182818284590452354 ]]) == '2.718281828459045') -- euler constant w/ 17 digit precision
|
||||
assert(EncodeJson(assert(DecodeJson[[ -9223372036854775808 ]])) == '-9223372036854775808') -- minimum 64-bit integer
|
||||
assert(EncodeJson(assert(DecodeJson[[ 9223372036854775807 ]])) == '9223372036854775807') -- maximum 64-bit integer
|
||||
assert(EncodeJson(assert(DecodeJson[[ 9223372036854775808 ]])) == '9223372036854776000') -- switches to double due to integer overflow
|
||||
assert(EncodeJson(assert(DecodeJson[[ -9223372036854775809 ]])) == '-9223372036854776000') -- switches to double due to integer underflow
|
||||
assert(EncodeJson(assert(DecodeJson[[ 9223372036854775807.0 ]])) == '9223372036854776000') -- switches to double due to period mark
|
||||
assert(EncodeJson(assert(DecodeJson[[ 2.7182818284590452354 ]])) == '2.718281828459045') -- euler constant w/ 17 digit precision
|
||||
assert( EncodeLua(assert(DecodeJson[[ 2.7182818284590452354 ]])) == '2.718281828459045') -- euler constant w/ 17 digit precision
|
||||
|
||||
res, err = DecodeJson[[ ]]
|
||||
assert(not res)
|
||||
assert(err == 'unexpected eof')
|
||||
|
||||
res, err = DecodeJson[[ {} {} ]]
|
||||
assert(not res)
|
||||
assert(err == "junk after expression")
|
||||
|
||||
res, err = DecodeJson[[ null ]]
|
||||
assert(not res)
|
||||
assert(err == "toplevel json can't be null")
|
||||
|
||||
res, err = DecodeJson[[ false ]]
|
||||
assert(not res)
|
||||
assert(err == "toplevel json can't be false")
|
||||
|
||||
res, err = DecodeJson[[ {3:4} ]]
|
||||
assert(not res)
|
||||
assert(err == "object key must be string")
|
||||
|
||||
res, err = DecodeJson[[ z ]]
|
||||
assert(not res)
|
||||
assert(err == "illegal character")
|
||||
|
||||
res, err = DecodeJson[[ "\e" ]]
|
||||
assert(not res)
|
||||
assert(err == "invalid escape character")
|
||||
|
||||
res, err = DecodeJson[[ {"key": } ]]
|
||||
assert(not res)
|
||||
assert(err == "unexpected '}'")
|
||||
|
||||
res, err = DecodeJson[[ {"key": ] ]]
|
||||
assert(not res)
|
||||
assert(err == "unexpected ']'")
|
||||
|
||||
res, err = DecodeJson[[ {"key": ]]
|
||||
assert(not res)
|
||||
assert(err == "unexpected eof")
|
||||
|
||||
res, err = DecodeJson[[ {true:3} ]]
|
||||
assert(not res)
|
||||
assert(err == "object key must be string")
|
||||
|
||||
res, err = DecodeJson('[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[')
|
||||
assert(not res)
|
||||
assert(err == "maximum depth exceeded")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- benchmark nanos ticks
|
||||
--------------------------------------------------------------------------------
|
||||
-- JsonParseEmpty 23 72
|
||||
-- JsonParseInteger 45 142
|
||||
-- JsonParseDouble 108 335
|
||||
-- JsonParseString 106 329
|
||||
-- JsonParseArray 243 754
|
||||
-- JsonParseObject 523 1622
|
||||
-- JsonParseEmpty 41 127
|
||||
-- JsonParseInteger 66 206
|
||||
-- JsonParseDouble 123 383
|
||||
-- JsonParseString 116 361
|
||||
-- JsonParseArray 256 793
|
||||
-- JsonParseObject 890 2756
|
||||
-- JsonEncodeArray 639 1979
|
||||
-- JsonEncodeObject 1333 4129
|
||||
|
||||
function JsonParseEmpty()
|
||||
DecodeJson[[]]
|
||||
|
@ -87,7 +133,15 @@ function JsonParseArray()
|
|||
end
|
||||
|
||||
function JsonParseObject()
|
||||
DecodeJson[[ {"3":"1", "4":"1", "5":"9"} ]]
|
||||
DecodeJson[[ {"3": "1", "4": "1", "5": {"3":"1", "4":"1", "5":"9"}} ]]
|
||||
end
|
||||
|
||||
function JsonEncodeArray()
|
||||
EncodeJson({2, 0, {5, 7, 3}})
|
||||
end
|
||||
|
||||
function JsonEncodeObject()
|
||||
EncodeJson({["3"]="1", ["4"]="1", ["5"]={["3"]="1", ["4"]="1", ["5"]="9"}})
|
||||
end
|
||||
|
||||
print('JsonParseEmpty', Benchmark(JsonParseEmpty))
|
||||
|
@ -96,3 +150,5 @@ print('JsonParseDouble', Benchmark(JsonParseDouble))
|
|||
print('JsonParseString', Benchmark(JsonParseString))
|
||||
print('JsonParseArray', Benchmark(JsonParseArray))
|
||||
print('JsonParseObject', Benchmark(JsonParseObject))
|
||||
print('JsonEncodeArr', Benchmark(JsonEncodeArray))
|
||||
print('JsonEncodeObj', Benchmark(JsonEncodeObject))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
|
@ -31,211 +30,225 @@
|
|||
-- ljson should reject all of them as invalid
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_no-colon.json
|
||||
assert(false == pcall(DecodeJson, ' {"a" '))
|
||||
assert(not DecodeJson(' {"a" '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_value.json
|
||||
assert(false == pcall(DecodeJson, ' {"a": '))
|
||||
assert(not DecodeJson(' {"a": '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_key.json
|
||||
assert(false == pcall(DecodeJson, ' {:"b"} '))
|
||||
assert(not DecodeJson(' {:"b"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_colon.json
|
||||
assert(false == pcall(DecodeJson, ' {"a" b} '))
|
||||
assert(not DecodeJson(' {"a" b} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_key_with_single_quotes.json
|
||||
assert(false == pcall(DecodeJson, ' {key: \'value\'} '))
|
||||
assert(not DecodeJson(' {key: \'value\'} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_garbage_at_end.json
|
||||
assert(false == pcall(DecodeJson, ' {"a":"a" 123} '))
|
||||
assert(not DecodeJson(' {"a":"a" 123} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_emoji.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x7b\xf0\x9f\x87\xa8\xf0\x9f\x87\xad\x7d '))
|
||||
assert(not DecodeJson(' \x7b\xf0\x9f\x87\xa8\xf0\x9f\x87\xad\x7d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_bracket_key.json
|
||||
assert(false == pcall(DecodeJson, ' {[: "x"} '))
|
||||
assert(not DecodeJson(' {[: "x"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_with_alpha_char.json
|
||||
assert(false == pcall(DecodeJson, ' [1.8011670033376514H-308] '))
|
||||
assert(not DecodeJson(' [1.8011670033376514H-308] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_with_alpha.json
|
||||
assert(false == pcall(DecodeJson, ' [1.2a-3] '))
|
||||
assert(not DecodeJson(' [1.2a-3] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_starting_with_dot.json
|
||||
assert(false == pcall(DecodeJson, ' [.123] '))
|
||||
assert(not DecodeJson(' [.123] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_real_with_invalid_utf8_after_e.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x31\x65\xe5\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x31\x65\xe5\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_real_garbage_after_e.json
|
||||
assert(false == pcall(DecodeJson, ' [1ea] '))
|
||||
assert(not DecodeJson(' [1ea] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_neg_with_garbage_at_end.json
|
||||
assert(false == pcall(DecodeJson, ' [-1x] '))
|
||||
assert(not DecodeJson(' [-1x] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_neg_real_without_int_part.json
|
||||
assert(false == pcall(DecodeJson, ' [-.123] '))
|
||||
assert(not DecodeJson(' [-.123] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_minus_sign_with_trailing_garbage.json
|
||||
assert(false == pcall(DecodeJson, ' [-foo] '))
|
||||
assert(not DecodeJson(' [-foo] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_minus_infinity.json
|
||||
assert(false == pcall(DecodeJson, ' [-Infinity] '))
|
||||
assert(not DecodeJson(' [-Infinity] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-utf-8-in-int.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x30\xe5\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x30\xe5\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-utf-8-in-exponent.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x31\x65\x31\xe5\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x31\x65\x31\xe5\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-utf-8-in-bigger-int.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x31\x32\x33\xe5\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x31\x32\x33\xe5\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid-negative-real.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x2d\x31\x32\x33\x2e\x31\x32\x33\x66\x6f\x6f\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x2d\x31\x32\x33\x2e\x31\x32\x33\x66\x6f\x6f\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_invalid+-.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x30\x65\x2b\x2d\x31\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x30\x65\x2b\x2d\x31\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_infinity.json
|
||||
assert(false == pcall(DecodeJson, ' [Infinity] '))
|
||||
assert(not DecodeJson(' [Infinity] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_hex_2_digits.json
|
||||
assert(false == pcall(DecodeJson, ' [0x42] '))
|
||||
assert(not DecodeJson(' [0x42] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_hex_1_digit.json
|
||||
assert(false == pcall(DecodeJson, ' [0x1] '))
|
||||
assert(not DecodeJson(' [0x1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_expression.json
|
||||
assert(false == pcall(DecodeJson, ' [1+2] '))
|
||||
assert(not DecodeJson(' [1+2] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_U+FF11_fullwidth_digit_one.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\xef\xbc\x91\x5d '))
|
||||
assert(not DecodeJson(' \x5b\xef\xbc\x91\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_NaN.json
|
||||
assert(false == pcall(DecodeJson, ' [NaN] '))
|
||||
assert(not DecodeJson(' [NaN] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_Inf.json
|
||||
assert(false == pcall(DecodeJson, ' [Inf] '))
|
||||
assert(not DecodeJson(' [Inf] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_9.e+.json
|
||||
assert(false == pcall(DecodeJson, ' [9.e+] '))
|
||||
assert(not DecodeJson(' [9.e+] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1eE2.json
|
||||
assert(false == pcall(DecodeJson, ' [1eE2] '))
|
||||
assert(not DecodeJson(' [1eE2] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1.0e.json
|
||||
assert(false == pcall(DecodeJson, ' [1.0e] '))
|
||||
assert(not DecodeJson(' [1.0e] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1.0e-.json
|
||||
assert(false == pcall(DecodeJson, ' [1.0e-] '))
|
||||
assert(not DecodeJson(' [1.0e-] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1.0e+.json
|
||||
assert(false == pcall(DecodeJson, ' [1.0e+] '))
|
||||
assert(not DecodeJson(' [1.0e+] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0e.json
|
||||
assert(false == pcall(DecodeJson, ' [0e] '))
|
||||
assert(not DecodeJson(' [0e] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0e+.json
|
||||
assert(false == pcall(DecodeJson, ' [0e+] '))
|
||||
assert(not DecodeJson(' [0e+] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0_capital_E.json
|
||||
assert(false == pcall(DecodeJson, ' [0E] '))
|
||||
assert(not DecodeJson(' [0E] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0_capital_E+.json
|
||||
assert(false == pcall(DecodeJson, ' [0E+] '))
|
||||
assert(not DecodeJson(' [0E+] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.3e.json
|
||||
assert(false == pcall(DecodeJson, ' [0.3e] '))
|
||||
assert(not DecodeJson(' [0.3e] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.3e+.json
|
||||
assert(false == pcall(DecodeJson, ' [0.3e+] '))
|
||||
assert(not DecodeJson(' [0.3e+] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.1.2.json
|
||||
assert(false == pcall(DecodeJson, ' [0.1.2] '))
|
||||
assert(not DecodeJson(' [0.1.2] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_.2e-3.json
|
||||
assert(false == pcall(DecodeJson, ' [.2e-3] '))
|
||||
assert(not DecodeJson(' [.2e-3] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_.-1.json
|
||||
assert(false == pcall(DecodeJson, ' [.-1] '))
|
||||
assert(not DecodeJson(' [.-1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_-NaN.json
|
||||
assert(false == pcall(DecodeJson, ' [-NaN] '))
|
||||
assert(not DecodeJson(' [-NaN] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_-1.0..json
|
||||
assert(false == pcall(DecodeJson, ' [-1.0.] '))
|
||||
assert(not DecodeJson(' [-1.0.] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_+Inf.json
|
||||
assert(false == pcall(DecodeJson, ' [+Inf] '))
|
||||
assert(not DecodeJson(' [+Inf] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_+1.json
|
||||
assert(false == pcall(DecodeJson, ' [+1] '))
|
||||
assert(not DecodeJson(' [+1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_++.json
|
||||
assert(false == pcall(DecodeJson, ' [++1234] '))
|
||||
assert(not DecodeJson(' [++1234] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_incomplete_true.json
|
||||
assert(false == pcall(DecodeJson, ' [tru] '))
|
||||
assert(not DecodeJson(' [tru] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_incomplete_null.json
|
||||
assert(false == pcall(DecodeJson, ' [nul] '))
|
||||
assert(not DecodeJson(' [nul] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_incomplete_false.json
|
||||
assert(false == pcall(DecodeJson, ' [fals] '))
|
||||
assert(not DecodeJson(' [fals] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed_with_object_inside.json
|
||||
assert(false == pcall(DecodeJson, ' [{} '))
|
||||
assert(not DecodeJson(' [{} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed_with_new_lines.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[1,
|
||||
1
|
||||
,1 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed_trailing_comma.json
|
||||
assert(false == pcall(DecodeJson, ' [1, '))
|
||||
assert(not DecodeJson(' [1, '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_unclosed.json
|
||||
assert(false == pcall(DecodeJson, ' ["" '))
|
||||
assert(not DecodeJson(' ["" '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_star_inside.json
|
||||
assert(false == pcall(DecodeJson, ' [*] '))
|
||||
assert(not DecodeJson(' [*] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_spaces_vertical_tab_formfeed.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x0b\x61\x22\x5c\x66\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x22\x0b\x61\x22\x5c\x66\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_newlines_unclosed.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
["a",
|
||||
4
|
||||
,1, ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_items_separated_by_semicolon.json
|
||||
assert(false == pcall(DecodeJson, ' [1:2] '))
|
||||
assert(not DecodeJson(' [1:2] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_invalid_utf8.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\xff\x5d '))
|
||||
assert(not DecodeJson(' \x5b\xff\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_incomplete_invalid_value.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x78 '))
|
||||
assert(not DecodeJson(' \x5b\x78 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_incomplete.json
|
||||
assert(false == pcall(DecodeJson, ' ["x" '))
|
||||
assert(not DecodeJson(' ["x" '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_colon_instead_of_comma.json
|
||||
assert(false == pcall(DecodeJson, ' ["": 1] '))
|
||||
assert(not DecodeJson(' ["": 1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_a_invalid_utf8.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x61\xe5\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x61\xe5\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_comma_instead_of_colon.json
|
||||
assert(not DecodeJson(' {"x", null} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_bad_value.json
|
||||
assert(not DecodeJson(' ["x", truth] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_multidigit_number_then_00.json
|
||||
assert(not DecodeJson(' 123\x00 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_extra_close.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(not DecodeJson([[
|
||||
[ "x"] ] ]]))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
|
@ -33,124 +32,156 @@
|
|||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_whitespace_formfeed.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x0c\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x0c\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_whitespace_U+2060_word_joiner.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\xe2\x81\xa0\x5d '))
|
||||
assert(not DecodeJson(' \x5b\xe2\x81\xa0\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unicode-identifier.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \xc3\xa5 '))
|
||||
assert(not DecodeJson(' \xc3\xa5 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_object.json
|
||||
assert(false == pcall(DecodeJson, ' {"asd":"asd" '))
|
||||
assert(not DecodeJson(' {"asd":"asd" '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array_unfinished_true.json
|
||||
assert(false == pcall(DecodeJson, ' [ false, tru '))
|
||||
assert(not DecodeJson(' [ false, tru '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array_unfinished_false.json
|
||||
assert(false == pcall(DecodeJson, ' [ true, fals '))
|
||||
assert(not DecodeJson(' [ true, fals '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array_partial_null.json
|
||||
assert(false == pcall(DecodeJson, ' [ false, nul '))
|
||||
assert(not DecodeJson(' [ false, nul '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_unclosed_array.json
|
||||
assert(false == pcall(DecodeJson, ' [1 '))
|
||||
assert(not DecodeJson(' [1 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_uescaped_LF_before_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x5c\x75\x30\x30\x30\x41\x22\x22\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x5c\x75\x30\x30\x30\x41\x22\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_single_star.json
|
||||
assert(false == pcall(DecodeJson, ' * '))
|
||||
assert(not DecodeJson(' * '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_single_eacute.json
|
||||
assert(false == pcall(DecodeJson, ' é '))
|
||||
assert(not DecodeJson(' é '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_open.json
|
||||
assert(false == pcall(DecodeJson, [[ ["{["{["{["{ ]]))
|
||||
assert(not DecodeJson([[ ["{["{["{["{ ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_string_with_apostrophes.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x7b\x27\x61\x27 '))
|
||||
assert(not DecodeJson(' \x7b\x27\x61\x27 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_open_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x7b\x22\x61 '))
|
||||
assert(not DecodeJson(' \x7b\x22\x61 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_open_array.json
|
||||
assert(false == pcall(DecodeJson, ' {[ '))
|
||||
assert(not DecodeJson(' {[ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_comma.json
|
||||
assert(false == pcall(DecodeJson, ' {, '))
|
||||
assert(not DecodeJson(' {, '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object_close_array.json
|
||||
assert(false == pcall(DecodeJson, ' {] '))
|
||||
assert(not DecodeJson(' {] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_object.json
|
||||
assert(false == pcall(DecodeJson, ' { '))
|
||||
assert(not DecodeJson(' { '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x61\x22 '))
|
||||
assert(not DecodeJson(' \x5b\x22\x61\x22 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_open_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x61 '))
|
||||
assert(not DecodeJson(' \x5b\x22\x61 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_open_object.json
|
||||
assert(false == pcall(DecodeJson, ' [{ '))
|
||||
assert(not DecodeJson(' [{ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_comma.json
|
||||
assert(false == pcall(DecodeJson, ' [, '))
|
||||
assert(not DecodeJson(' [, '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_apostrophe.json
|
||||
assert(false == pcall(DecodeJson, ' [\' '))
|
||||
assert(not DecodeJson(' [\' '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_with_comment.json
|
||||
assert(false == pcall(DecodeJson, ' {"a":/*comment*/"b"} '))
|
||||
assert(not DecodeJson(' {"a":/*comment*/"b"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_unclosed_no_value.json
|
||||
assert(false == pcall(DecodeJson, ' {"": '))
|
||||
assert(not DecodeJson(' {"": '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_null-byte-outside-string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x00\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x00\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_lone-open-bracket.json
|
||||
assert(false == pcall(DecodeJson, ' [ '))
|
||||
assert(not DecodeJson(' [ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_lone-invalid-utf-8.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \xe5 '))
|
||||
assert(not DecodeJson(' \xe5 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_incomplete_UTF8_BOM.json
|
||||
assert(false == pcall(DecodeJson, ' ï»{} '))
|
||||
assert(not DecodeJson(' ï»{} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_comma_instead_of_closing_brace.json
|
||||
assert(false == pcall(DecodeJson, ' {"x": true, '))
|
||||
assert(not DecodeJson(' {"x": true, '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_capitalized_True.json
|
||||
assert(false == pcall(DecodeJson, ' [True] '))
|
||||
assert(not DecodeJson(' [True] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_ascii-unicode-identifier.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x61\xc3\xa5 '))
|
||||
assert(not DecodeJson(' \x61\xc3\xa5 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_array_with_unclosed_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x61\x73\x64\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x22\x61\x73\x64\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_angle_bracket_null.json
|
||||
assert(false == pcall(DecodeJson, ' [<null>] '))
|
||||
assert(not DecodeJson(' [<null>] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_angle_bracket_..json
|
||||
assert(false == pcall(DecodeJson, ' <.> '))
|
||||
assert(not DecodeJson(' <.> '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_UTF8_BOM_no_data.json
|
||||
assert(false == pcall(DecodeJson, '  '))
|
||||
assert(not DecodeJson('  '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_U+2060_word_joined.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\xe2\x81\xa0\x5d '))
|
||||
assert(not DecodeJson(' \x5b\xe2\x81\xa0\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_trailing_#.json
|
||||
assert(not DecodeJson(' {"a":"b"}#{} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_with_trailing_garbage.json
|
||||
assert(not DecodeJson(' {"a": true} "x" '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_followed_by_closing_object.json
|
||||
assert(not DecodeJson(' {}} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_number_with_trailing_garbage.json
|
||||
assert(not DecodeJson(' 2@ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_no_data.json
|
||||
assert(not DecodeJson(' '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_end_array.json
|
||||
assert(not DecodeJson(' ] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_double_array.json
|
||||
assert(not DecodeJson(' [][] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_close_unopened_array.json
|
||||
assert(not DecodeJson(' 1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_array_with_extra_array_close.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(not DecodeJson([[
|
||||
[ 1] ] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_array_trailing_garbage.json
|
||||
assert(not DecodeJson(' [1]x '))
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
-- ljson should reject all of them as invalid
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_open_array_object.json
|
||||
assert(false == pcall(DecodeJson, [[ [{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"
|
||||
assert(not DecodeJson([[ [{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"
|
||||
":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"
|
||||
":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"
|
||||
":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"
|
||||
|
@ -3161,7 +3161,7 @@ assert(false == pcall(DecodeJson, [[ [{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"":[{"
|
|||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_100000_opening_arrays.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [
|
||||
|
|
|
@ -32,68 +32,145 @@
|
|||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_start_escape_unclosed.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x5c '))
|
||||
assert(not DecodeJson(' \x5b\x22\x5c '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_string_no_double_quotes.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x61\x62\x63 '))
|
||||
assert(not DecodeJson(' \x61\x62\x63 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_quote.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x27\x73\x69\x6e\x67\x6c\x65\x20\x71\x75\x6f\x74\x65\x27\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x27\x73\x69\x6e\x67\x6c\x65\x20\x71\x75\x6f\x74\x65\x27\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_no_quotes_with_bad_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x5c\x6e\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x5c\x6e\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_leading_uescaped_thinspace.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x5c\x75\x30\x30\x32\x30\x22\x61\x73\x64\x22\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x5c\x75\x30\x30\x32\x30\x22\x61\x73\x64\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_surrogate_escape_invalid.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x44\x38\x30\x30\x5c\x78\x22\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x44\x38\x30\x30\x5c\x78\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x5c\x22\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_backslash_bad.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x5c\x5c\x5c\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escape_x.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x5c\x78\x30\x30\x22\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x5c\x5c\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_accentuated_char_no_quotes.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\xc3\xa9\x5d '))
|
||||
assert(not DecodeJson(' \x5b\xc3\xa9\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x22\x5d '))
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_with_single_string.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x7b\x20\x22\x66\x6f\x6f\x22\x20\x3a\x20\x22\x62\x61\x72\x22\x2c\x20\x22\x61\x22\x20\x7d '))
|
||||
assert(not DecodeJson(' \x7b\x20\x22\x66\x6f\x6f\x22\x20\x3a\x20\x22\x62\x61\x72\x22\x2c\x20\x22\x61\x22\x20\x7d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_unterminated-value.json
|
||||
assert(false == pcall(DecodeJson, ' {"a":"a '))
|
||||
assert(not DecodeJson(' {"a":"a '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_unquoted_key.json
|
||||
assert(false == pcall(DecodeJson, ' {a: "b"} '))
|
||||
assert(not DecodeJson(' {a: "b"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_single_quote.json
|
||||
assert(false == pcall(DecodeJson, ' {\'a\':0} '))
|
||||
assert(not DecodeJson(' {\'a\':0} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_repeated_null_null.json
|
||||
assert(false == pcall(DecodeJson, ' {null:null,null:null} '))
|
||||
assert(not DecodeJson(' {null:null,null:null} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_non_string_key_but_huge_number_instead.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x7b\x39\x39\x39\x39\x45\x39\x39\x39\x39\x3a\x31\x7d '))
|
||||
assert(not DecodeJson(' \x7b\x39\x39\x39\x39\x45\x39\x39\x39\x39\x3a\x31\x7d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_non_string_key.json
|
||||
-- (converted to binary for safety)
|
||||
assert(false == pcall(DecodeJson, ' \x7b\x31\x3a\x31\x7d '))
|
||||
assert(not DecodeJson(' \x7b\x31\x3a\x31\x7d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_comma_after_close.json
|
||||
assert(not DecodeJson(' [""], '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_backslash_00.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x00\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_emoji.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\xf0\x9f\x8c\x80\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_ctrl_char_tab.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x09\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_surrogate.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x44\x38\x33\x34\x5c\x75\x44\x64\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_escaped_character.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x30\x30\x41\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_doublequote.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x22 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_utf8_after_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\xe5\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_unicode_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x71\x71\x71\x71\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_backslash_esc.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x61\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid-utf-8-in-escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\xe5\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u1x.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x31\x78\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u1.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x31\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unicode_CapitalU.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(' \x22\x5c\x55\x41\x36\x36\x44\x22 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_with_trailing_garbage.json
|
||||
-- (converted to binary for safety)
|
||||
assert(not DecodeJson(" \"\"x "))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_single_space.json
|
||||
assert(not DecodeJson(' '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_with_trailing_garbage.json
|
||||
assert(not DecodeJson(' {"a":"b"}# '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment_slash_open_incomplete.json
|
||||
assert(not DecodeJson(' {"a":"b"}/ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment_slash_open.json
|
||||
assert(not DecodeJson(' {"a":"b"}// '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment_open.json
|
||||
assert(not DecodeJson(' {"a":"b"}/**// '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment.json
|
||||
assert(not DecodeJson(' {"a":"b"}/**/ '))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
|
@ -27,241 +26,111 @@
|
|||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
-- these test cases are prefixed with n_, but
|
||||
-- ljson doesn't reject any of them as invalid
|
||||
-- we run these tests anyway just to ensure that
|
||||
-- no segfaults occurs while parsing these cases
|
||||
|
||||
-- from fail4.lua
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_backslash_00.json
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escape_x.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x00\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_emoji.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\xf0\x9f\x8c\x80\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_escaped_ctrl_char_tab.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x09\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_surrogate.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\x44\x38\x33\x34\x5c\x75\x44\x64\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_incomplete_escaped_character.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\x30\x30\x41\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_single_doublequote.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x22 '))
|
||||
assert(DecodeJson(" [\"\\x00\"] "))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unescaped_tab.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x09\x22\x5d '))
|
||||
assert(DecodeJson([[ [" "] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unescaped_newline.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x6e\x65\x77\x0a\x6c\x69\x6e\x65\x22\x5d '))
|
||||
assert(DecodeJson(" [\"new\nline\"] "))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unescaped_ctrl_char.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x61\x00\x61\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_utf8_after_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\xe5\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_unicode_escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\x71\x71\x71\x71\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid_backslash_esc.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x61\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_invalid-utf-8-in-escape.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\xe5\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u1x.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x31\x78\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u1.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x31\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_1_surrogate_then_escape_u.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x5b\x22\x5c\x75\x44\x38\x30\x30\x5c\x75\x22\x5d '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_unicode_CapitalU.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x22\x5c\x55\x41\x36\x36\x44\x22 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_string_with_trailing_garbage.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x22\x22\x78 '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_single_space.json
|
||||
assert(nil ~= pcall(DecodeJson, ' '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_with_trailing_garbage.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b"}# '))
|
||||
assert(assert(EncodeLua(assert(DecodeJson(" [\"a\x00a\"] ")))) == assert(EncodeLua({"a\x00a"})))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_two_commas_in_a_row.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b",,"c":"d"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment_slash_open_incomplete.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b"}/ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment_slash_open.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b"}// '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment_open.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b"}/**// '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comment.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b"}/**/ '))
|
||||
assert(assert(EncodeLua(assert(DecodeJson(' {"a":"b",,"c":"d"} ')))) == assert(EncodeLua({a="b", c="d"})))
|
||||
assert(DecodeJson(' {"a":"b",,"c":"d"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_trailing_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"id":0,} '))
|
||||
assert(DecodeJson(' {"id":0,} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_several_trailing_commas.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"id":0,,,,,} '))
|
||||
|
||||
-- from fail2.lua
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_trailing_#.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a":"b"}#{} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_with_trailing_garbage.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a": true} "x" '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_object_followed_by_closing_object.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {}} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_number_with_trailing_garbage.json
|
||||
assert(nil ~= pcall(DecodeJson, ' 2@ '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_no_data.json
|
||||
assert(nil ~= pcall(DecodeJson, ' '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_end_array.json
|
||||
assert(nil ~= pcall(DecodeJson, ' ] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_double_array.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [][] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_close_unopened_array.json
|
||||
assert(nil ~= pcall(DecodeJson, ' 1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_array_with_extra_array_close.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ 1] ] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_structure_array_trailing_garbage.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1]x '))
|
||||
|
||||
assert(DecodeJson(' {"id":0,,,,,} '))
|
||||
|
||||
-- from fail1.lua
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json
|
||||
-- (converted to binary for safety)
|
||||
assert(nil ~= pcall(DecodeJson, ' \x7b\x22\xb9\x22\x3a\x22\x30\x22\x2c\x7d '))
|
||||
assert(DecodeJson(" {\"\xb9\":\"0\",} "))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_missing_semicolon.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"a" "b"} '))
|
||||
assert(DecodeJson(' {"a" "b"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_double_colon.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"x"::"b"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_comma_instead_of_colon.json
|
||||
assert(nil ~= pcall(DecodeJson, ' {"x", null} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_object_bad_value.json
|
||||
assert(nil ~= pcall(DecodeJson, ' ["x", truth] '))
|
||||
assert(DecodeJson(' {"x"::"b"} '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_with_leading_zero.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [012] '))
|
||||
assert(DecodeJson(' [012] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_real_without_fractional_part.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1.] '))
|
||||
assert(DecodeJson(' [1.] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_neg_int_starting_with_zero.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [-012] '))
|
||||
assert(DecodeJson(' [-012] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_minus_space_1.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [- 1] '))
|
||||
assert(DecodeJson(' [- 1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_2.e3.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [2.e3] '))
|
||||
assert(DecodeJson(' [2.e3] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_2.e-3.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [2.e-3] '))
|
||||
assert(DecodeJson(' [2.e-3] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_2.e+3.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [2.e+3] '))
|
||||
assert(DecodeJson(' [2.e+3] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_1_000.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1 000.0] '))
|
||||
assert(DecodeJson(' [1 000.0] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_0.e1.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [0.e1] '))
|
||||
assert(DecodeJson(' [0.e1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_-2..json
|
||||
assert(nil ~= pcall(DecodeJson, ' [-2.] '))
|
||||
assert(DecodeJson(' [-2.] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_number_-01.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [-01] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_multidigit_number_then_00.json
|
||||
assert(nil ~= pcall(DecodeJson, ' 123\x00 '))
|
||||
assert(DecodeJson(' [-01] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_number_and_several_commas.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1,,] '))
|
||||
assert(DecodeJson(' [1,,] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_number_and_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1,] '))
|
||||
assert(DecodeJson(' [1,] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_missing_value.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [ , ""] '))
|
||||
assert(DecodeJson(' [ , ""] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_just_minus.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [-] '))
|
||||
assert(DecodeJson(' [-] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_just_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [,] '))
|
||||
assert(DecodeJson(' [,] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_inner_array_no_comma.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ 3[ 4] ] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_extra_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' ["",] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_extra_close.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "x"] ] ]]))
|
||||
assert(DecodeJson(' ["",] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_double_extra_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' ["x",,] '))
|
||||
assert(DecodeJson(' ["x",,] '))
|
||||
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_double_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1,,2] '))
|
||||
assert(DecodeJson(' [1,,2] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_comma_and_number.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [,1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_comma_after_close.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [""], '))
|
||||
assert(DecodeJson(' [,1] '))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/n_array_1_true_without_comma.json
|
||||
assert(nil ~= pcall(DecodeJson, ' [1 true] '))
|
||||
assert(DecodeJson(' [1 true] '))
|
||||
|
|
|
@ -32,294 +32,294 @@
|
|||
-- ljson should accept all of them as valid
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_whitespace_array.json
|
||||
assert(true == pcall(DecodeJson, [[ [] ]]))
|
||||
assert(DecodeJson([[ [] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_true_in_array.json
|
||||
assert(true == pcall(DecodeJson, [[ [true] ]]))
|
||||
assert(DecodeJson([[ [true] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_trailing_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a"] ]]))
|
||||
assert(DecodeJson([[ ["a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_string_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ "" ]]))
|
||||
assert(DecodeJson([[ "" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_true.json
|
||||
assert(true == pcall(DecodeJson, [[ true ]]))
|
||||
assert(DecodeJson([[ true ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_string.json
|
||||
assert(true == pcall(DecodeJson, [[ "asd" ]]))
|
||||
assert(DecodeJson([[ "asd" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_null.json
|
||||
assert(true == pcall(DecodeJson, [[ null ]]))
|
||||
assert(not DecodeJson([[ null ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_negative_real.json
|
||||
assert(true == pcall(DecodeJson, [[ -0.1 ]]))
|
||||
assert(DecodeJson([[ -0.1 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_int.json
|
||||
assert(true == pcall(DecodeJson, [[ 42 ]]))
|
||||
assert(DecodeJson([[ 42 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_false.json
|
||||
assert(true == pcall(DecodeJson, [[ false ]]))
|
||||
assert(not DecodeJson([[ false ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_with_del_character.json
|
||||
assert(true == pcall(DecodeJson, [[ ["aa"] ]]))
|
||||
assert(DecodeJson([[ ["aa"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_utf8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["€𝄞"] ]]))
|
||||
assert(DecodeJson([[ ["€𝄞"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_escaped_double_quote.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0022"] ]]))
|
||||
assert(DecodeJson([[ ["\u0022"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+FFFE_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFFFE"] ]]))
|
||||
assert(DecodeJson([[ ["\uFFFE"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+FDD0_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFDD0"] ]]))
|
||||
assert(DecodeJson([[ ["\uFDD0"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+2064_invisible_plus.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u2064"] ]]))
|
||||
assert(DecodeJson([[ ["\u2064"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u200B"] ]]))
|
||||
assert(DecodeJson([[ ["\u200B"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+1FFFE_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uD83F\uDFFE"] ]]))
|
||||
assert(DecodeJson([[ ["\uD83F\uDFFE"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+10FFFE_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uDBFF\uDFFE"] ]]))
|
||||
assert(DecodeJson([[ ["\uDBFF\uDFFE"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_2.json
|
||||
assert(true == pcall(DecodeJson, [[ ["⍂㈴⍂"] ]]))
|
||||
assert(DecodeJson([[ ["⍂㈴⍂"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicodeEscapedBackslash.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u005C"] ]]))
|
||||
assert(DecodeJson([[ ["\u005C"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uA66D"] ]]))
|
||||
assert(DecodeJson([[ ["\uA66D"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unescaped_char_delete.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
assert(DecodeJson([[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uescaped_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["new\u000Aline"] ]]))
|
||||
assert(DecodeJson([[ ["new\u000Aline"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uEscape.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0061\u30af\u30EA\u30b9"] ]]))
|
||||
assert(DecodeJson([[ ["\u0061\u30af\u30EA\u30b9"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_u+2029_par_sep.json
|
||||
assert(true == pcall(DecodeJson, [[ ["
"] ]]))
|
||||
assert(DecodeJson([[ ["
"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_u+2028_line_sep.json
|
||||
assert(true == pcall(DecodeJson, [[ ["
"] ]]))
|
||||
assert(DecodeJson([[ ["
"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_two-byte-utf-8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0123"] ]]))
|
||||
assert(DecodeJson([[ ["\u0123"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_three-byte-utf-8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0821"] ]]))
|
||||
assert(DecodeJson([[ ["\u0821"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uD834\uDd1e"] ]]))
|
||||
assert(DecodeJson([[ ["\uD834\uDd1e"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_space.json
|
||||
assert(true == pcall(DecodeJson, [[ " " ]]))
|
||||
assert(DecodeJson([[ " " ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_simple_ascii.json
|
||||
assert(true == pcall(DecodeJson, [[ ["asd "] ]]))
|
||||
assert(DecodeJson([[ ["asd "] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
assert(DecodeJson([[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_pi.json
|
||||
assert(true == pcall(DecodeJson, [[ ["π"] ]]))
|
||||
assert(DecodeJson([[ ["π"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_one-byte-utf-8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u002c"] ]]))
|
||||
assert(DecodeJson([[ ["\u002c"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_null_escape.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0000"] ]]))
|
||||
assert(DecodeJson([[ ["\u0000"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
assert(DecodeJson([[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
assert(DecodeJson([[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_nbsp_uescaped.json
|
||||
assert(true == pcall(DecodeJson, [[ ["new\u00A0line"] ]]))
|
||||
assert(DecodeJson([[ ["new\u00A0line"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_last_surrogates_1_and_2.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uDBFF\uDFFF"] ]]))
|
||||
assert(DecodeJson([[ ["\uDBFF\uDFFF"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_in_array_with_leading_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [ "asd"] ]]))
|
||||
assert(DecodeJson([[ [ "asd"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_in_array.json
|
||||
assert(true == pcall(DecodeJson, [[ ["asd"] ]]))
|
||||
assert(DecodeJson([[ ["asd"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_escaped_noncharacter.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFFFF"] ]]))
|
||||
assert(DecodeJson([[ ["\uFFFF"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_escaped_control_character.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0012"] ]]))
|
||||
assert(DecodeJson([[ ["\u0012"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_double_escape_n.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\\n"] ]]))
|
||||
assert(DecodeJson([[ ["\\n"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_double_escape_a.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\\a"] ]]))
|
||||
assert(DecodeJson([[ ["\\a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_comments.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a/*b*/c/*d//e"] ]]))
|
||||
assert(DecodeJson([[ ["a/*b*/c/*d//e"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_backslash_doublequotes.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\""] ]]))
|
||||
assert(DecodeJson([[ ["\""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_backslash_and_u_escaped_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\\u0000"] ]]))
|
||||
assert(DecodeJson([[ ["\\u0000"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_allowed_escapes.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\"\\\/\b\f\n\r\t"] ]]))
|
||||
assert(DecodeJson([[ ["\"\\\/\b\f\n\r\t"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_accepted_surrogate_pairs.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\ud83d\ude39\ud83d\udc8d"] ]]))
|
||||
assert(DecodeJson([[ ["\ud83d\ude39\ud83d\udc8d"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_accepted_surrogate_pair.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uD801\udc37"] ]]))
|
||||
assert(DecodeJson([[ ["\uD801\udc37"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0060\u012a\u12AB"] ]]))
|
||||
assert(DecodeJson([[ ["\u0060\u012a\u12AB"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_with_newlines.json
|
||||
assert(true == pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
{
|
||||
"a": "b"
|
||||
} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_string_unicode.json
|
||||
assert(true == pcall(DecodeJson, [[ {"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } ]]))
|
||||
assert(DecodeJson([[ {"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_simple.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":[]} ]]))
|
||||
assert(DecodeJson([[ {"a":[]} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_long_strings.json
|
||||
assert(true == pcall(DecodeJson, [[ {"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} ]]))
|
||||
assert(DecodeJson([[ {"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_extreme_numbers.json
|
||||
assert(true == pcall(DecodeJson, [[ { "min": -1.0e+28, "max": 1.0e+28 } ]]))
|
||||
assert(DecodeJson([[ { "min": -1.0e+28, "max": 1.0e+28 } ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_escaped_null_in_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"foo\u0000bar": 42} ]]))
|
||||
assert(DecodeJson([[ {"foo\u0000bar": 42} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_empty_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"":0} ]]))
|
||||
assert(DecodeJson([[ {"":0} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ {} ]]))
|
||||
assert(DecodeJson([[ {} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key_and_value.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"b"} ]]))
|
||||
assert(DecodeJson([[ {"a":"b","a":"b"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"c"} ]]))
|
||||
assert(DecodeJson([[ {"a":"b","a":"c"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_basic.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf"} ]]))
|
||||
assert(DecodeJson([[ {"asd":"sdf"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf", "dfg":"fgh"} ]]))
|
||||
assert(DecodeJson([[ {"asd":"sdf", "dfg":"fgh"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_simple_real.json
|
||||
assert(true == pcall(DecodeJson, [[ [123.456789] ]]))
|
||||
assert(DecodeJson([[ [123.456789] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_simple_int.json
|
||||
assert(true == pcall(DecodeJson, [[ [123] ]]))
|
||||
assert(DecodeJson([[ [123] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_pos_exponent.json
|
||||
assert(true == pcall(DecodeJson, [[ [1e+2] ]]))
|
||||
assert(DecodeJson([[ [1e+2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_neg_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [1e-2] ]]))
|
||||
assert(DecodeJson([[ [1e-2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_fraction_exponent.json
|
||||
assert(true == pcall(DecodeJson, [[ [123.456e78] ]]))
|
||||
assert(DecodeJson([[ [123.456e78] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_exponent.json
|
||||
assert(true == pcall(DecodeJson, [[ [123e45] ]]))
|
||||
assert(DecodeJson([[ [123e45] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_capital_e_pos_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [1E+2] ]]))
|
||||
assert(DecodeJson([[ [1E+2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_capital_e_neg_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [1E-2] ]]))
|
||||
assert(DecodeJson([[ [1E-2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_capital_e.json
|
||||
assert(true == pcall(DecodeJson, [[ [1E22] ]]))
|
||||
assert(DecodeJson([[ [1E22] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_negative_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0] ]]))
|
||||
assert(DecodeJson([[ [-0] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_negative_one.json
|
||||
assert(true == pcall(DecodeJson, [[ [-1] ]]))
|
||||
assert(DecodeJson([[ [-1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_negative_int.json
|
||||
assert(true == pcall(DecodeJson, [[ [-123] ]]))
|
||||
assert(DecodeJson([[ [-123] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_minus_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0] ]]))
|
||||
assert(DecodeJson([[ [-0] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_int_with_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [20e1] ]]))
|
||||
assert(DecodeJson([[ [20e1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_double_close_to_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] ]]))
|
||||
assert(DecodeJson([[ [-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_after_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [ 4] ]]))
|
||||
assert(DecodeJson([[ [ 4] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_0e1.json
|
||||
assert(true == pcall(DecodeJson, [[ [0e1] ]]))
|
||||
assert(DecodeJson([[ [0e1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_0e+1.json
|
||||
assert(true == pcall(DecodeJson, [[ [0e+1] ]]))
|
||||
assert(DecodeJson([[ [0e+1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number.json
|
||||
assert(true == pcall(DecodeJson, [[ [123e65] ]]))
|
||||
assert(DecodeJson([[ [123e65] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_trailing_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [2] ]]))
|
||||
assert(DecodeJson([[ [2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_several_null.json
|
||||
assert(true == pcall(DecodeJson, [[ [1,null,null,null,2] ]]))
|
||||
assert(DecodeJson([[ [1,null,null,null,2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_leading_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [1] ]]))
|
||||
assert(DecodeJson([[ [1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_1_and_newline.json
|
||||
assert(true == pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[1
|
||||
] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_null.json
|
||||
assert(true == pcall(DecodeJson, [[ [null] ]]))
|
||||
assert(DecodeJson([[ [null] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_heterogeneous.json
|
||||
assert(true == pcall(DecodeJson, [[ [null, 1, "1", {}] ]]))
|
||||
assert(DecodeJson([[ [null, 1, "1", {}] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_false.json
|
||||
assert(true == pcall(DecodeJson, [[ [false] ]]))
|
||||
assert(DecodeJson([[ [false] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_ending_with_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a"] ]]))
|
||||
assert(DecodeJson([[ ["a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ [] ]]))
|
||||
assert(DecodeJson([[ [] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty-string.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
assert(DecodeJson([[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_arraysWithSpaces.json
|
||||
-- (added spaces between [[ and ]] so lua doesn't get confused)
|
||||
assert(true == pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ [ ] ] ]]))
|
||||
|
||||
|
|
|
@ -1,101 +1,132 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail11.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
{"Illegal expression": 1 + 2}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail12.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
{"Illegal invocation": alert()}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail13.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
{"Numbers cannot have leading zeroes": 013}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail14.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
{"Numbers cannot be hex": 0x14}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail15.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Illegal backslash escape: \x15"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail16.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ \naked]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail17.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ "Illegal backslash escape: \017"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail22.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ "Colon instead of comma": false]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail23.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ "Bad value", truth]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail24.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ 'single quote']
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail29.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ 0e]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail2.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ "Unclosed array"
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail30.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ 0e+]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail31.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ 0e+-1]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail32.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
{"Comma instead if closing brace": true,
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail33.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
[ "mismatch"}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail3.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
assert(not DecodeJson([[
|
||||
{unquoted_key: "keys must be quoted"}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail21.json
|
||||
assert(not DecodeJson([[
|
||||
{"Comma instead of colon", null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail8.json
|
||||
assert(not DecodeJson([[
|
||||
[ "Extra close"] ]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail7.json
|
||||
assert(not DecodeJson([[
|
||||
[ "Comma after the close"] ,
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail10.json
|
||||
assert(not DecodeJson([[
|
||||
{"Extra value after close": true} "misplaced quoted value"
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail26.json
|
||||
assert(not DecodeJson([[
|
||||
[ "tab\ character\ in\ string\ "]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail28.json
|
||||
assert(not DecodeJson([[
|
||||
[ "line\
|
||||
break"]
|
||||
]]))
|
||||
|
|
|
@ -5,86 +5,55 @@
|
|||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail4.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ "extra comma",]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail5.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ "double extra comma",,]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail6.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ , "<-- missing value"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail7.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "Comma after the close"] ,
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail8.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "Extra close"] ]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail9.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
{"Extra comma": true,}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail19.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
{"Missing colon" null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail20.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
{"Double colon":: null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail21.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Comma instead of colon", null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail10.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Extra value after close": true} "misplaced quoted value"
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail25.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ " tab character in string "]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail26.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "tab\ character\ in\ string\ "]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail27.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
assert(DecodeJson([[
|
||||
[ "line
|
||||
break"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail28.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "line\
|
||||
break"]
|
||||
-- JSON parsing sample test case: fail15.json
|
||||
assert(DecodeJson([[
|
||||
[ "Illegal backslash escape: \x15"]
|
||||
]]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue