mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Add more json tests for ljson (#478)
This commit is contained in:
parent
11a1c62d11
commit
594615a0ff
43 changed files with 961 additions and 203 deletions
407
test/tool/net/samples/JSONTestSuite-fail.lua
Normal file
407
test/tool/net/samples/JSONTestSuite-fail.lua
Normal file
File diff suppressed because one or more lines are too long
BIN
test/tool/net/samples/JSONTestSuite-lenient.lua
Normal file
BIN
test/tool/net/samples/JSONTestSuite-lenient.lua
Normal file
Binary file not shown.
BIN
test/tool/net/samples/JSONTestSuite-okay.lua
Normal file
BIN
test/tool/net/samples/JSONTestSuite-okay.lua
Normal file
Binary file not shown.
325
test/tool/net/samples/JSONTestSuite-pass.lua
Normal file
325
test/tool/net/samples/JSONTestSuite-pass.lua
Normal file
|
@ -0,0 +1,325 @@
|
|||
--
|
||||
--
|
||||
-- Nicolas Seriot's JSONTestSuite
|
||||
-- https://github.com/nst/JSONTestSuite
|
||||
-- commit d64aefb55228d9584d3e5b2433f720ea8fd00c82
|
||||
--
|
||||
-- MIT License
|
||||
--
|
||||
-- Copyright (c) 2016 Nicolas Seriot
|
||||
--
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
-- of this software and associated documentation files (the "Software"), to deal
|
||||
-- in the Software without restriction, including without limitation the rights
|
||||
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
-- copies of the Software, and to permit persons to whom the Software is
|
||||
-- furnished to do so, subject to the following conditions:
|
||||
--
|
||||
-- The above copyright notice and this permission notice shall be included in all
|
||||
-- copies or substantial portions of the Software.
|
||||
--
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
|
||||
-- these test cases are prefixed with y_
|
||||
-- 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, [[ [] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_true_in_array.json
|
||||
assert(true == pcall(DecodeJson, [[ [true] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_trailing_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_string_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ "" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_true.json
|
||||
assert(true == pcall(DecodeJson, [[ true ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_string.json
|
||||
assert(true == pcall(DecodeJson, [[ "asd" ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_null.json
|
||||
assert(true == pcall(DecodeJson, [[ null ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_negative_real.json
|
||||
assert(true == pcall(DecodeJson, [[ -0.1 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_int.json
|
||||
assert(true == pcall(DecodeJson, [[ 42 ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_structure_lonely_false.json
|
||||
assert(true == pcall(DecodeJson, [[ false ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_with_del_character.json
|
||||
assert(true == pcall(DecodeJson, [[ ["aa"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_utf8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["€𝄞"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+FFFE_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFFFE"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+FDD0_nonchar.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFDD0"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+2064_invisible_plus.json
|
||||
assert(true == pcall(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"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_U+1FFFE_nonchar.json
|
||||
assert(true == pcall(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"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uA66D"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_escaped_double_quote.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0022"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicodeEscapedBackslash.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u005C"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unicode_2.json
|
||||
assert(true == pcall(DecodeJson, [[ ["⍂㈴⍂"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_unescaped_char_delete.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uEscape.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0061\u30af\u30EA\u30b9"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_uescaped_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["new\u000Aline"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_u+2029_par_sep.json
|
||||
assert(true == pcall(DecodeJson, [[ ["
"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_u+2028_line_sep.json
|
||||
assert(true == pcall(DecodeJson, [[ ["
"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_two-byte-utf-8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0123"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_three-byte-utf-8.json
|
||||
assert(true == pcall(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"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_space.json
|
||||
assert(true == pcall(DecodeJson, [[ " " ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_simple_ascii.json
|
||||
assert(true == pcall(DecodeJson, [[ ["asd "] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_pi.json
|
||||
assert(true == pcall(DecodeJson, [[ ["π"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_one-byte-utf-8.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u002c"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_null_escape.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0000"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_nbsp_uescaped.json
|
||||
assert(true == pcall(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"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_in_array_with_leading_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [ "asd"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_in_array.json
|
||||
assert(true == pcall(DecodeJson, [[ ["asd"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_escaped_noncharacter.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\uFFFF"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_escaped_control_character.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\u0012"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_double_escape_n.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\\n"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_double_escape_a.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\\a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_comments.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a/*b*/c/*d//e"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_backslash_doublequotes.json
|
||||
assert(true == pcall(DecodeJson, [[ ["\""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_backslash_and_u_escaped_zero.json
|
||||
assert(true == pcall(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"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_string_accepted_surrogate_pairs.json
|
||||
assert(true == pcall(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"] ]]))
|
||||
|
||||
-- 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"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_with_newlines.json
|
||||
assert(true == pcall(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" } ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_simple.json
|
||||
assert(true == pcall(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"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf", "dfg":"fgh"} ]]))
|
||||
|
||||
-- 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 } ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_escaped_null_in_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"foo\u0000bar": 42} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_empty_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"":0} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_empty.json
|
||||
assert(true == pcall(DecodeJson, [[ {} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"c"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_duplicated_key_and_value.json
|
||||
assert(true == pcall(DecodeJson, [[ {"a":"b","a":"b"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_object_basic.json
|
||||
assert(true == pcall(DecodeJson, [[ {"asd":"sdf"} ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_simple_real.json
|
||||
assert(true == pcall(DecodeJson, [[ [123.456789] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_simple_int.json
|
||||
assert(true == pcall(DecodeJson, [[ [123] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_pos_exponent.json
|
||||
assert(true == pcall(DecodeJson, [[ [1e+2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_neg_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [1e-2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_fraction_exponent.json
|
||||
assert(true == pcall(DecodeJson, [[ [123.456e78] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_exponent.json
|
||||
assert(true == pcall(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] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_capital_e_neg_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [1E-2] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_real_capital_e.json
|
||||
assert(true == pcall(DecodeJson, [[ [1E22] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_negative_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_negative_one.json
|
||||
assert(true == pcall(DecodeJson, [[ [-1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_negative_int.json
|
||||
assert(true == pcall(DecodeJson, [[ [-123] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_minus_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number.json
|
||||
assert(true == pcall(DecodeJson, [[ [123e65] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_int_with_exp.json
|
||||
assert(true == pcall(DecodeJson, [[ [20e1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_double_close_to_zero.json
|
||||
assert(true == pcall(DecodeJson, [[ [-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_after_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [ 4] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_0e1.json
|
||||
assert(true == pcall(DecodeJson, [[ [0e1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_number_0e+1.json
|
||||
assert(true == pcall(DecodeJson, [[ [0e+1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_trailing_space.json
|
||||
assert(true == pcall(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] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_leading_space.json
|
||||
assert(true == pcall(DecodeJson, [[ [1] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_with_1_and_newline.json
|
||||
assert(true == pcall(DecodeJson, [[
|
||||
[1
|
||||
] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_null.json
|
||||
assert(true == pcall(DecodeJson, [[ [null] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_heterogeneous.json
|
||||
assert(true == pcall(DecodeJson, [[ [null, 1, "1", {}] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_false.json
|
||||
assert(true == pcall(DecodeJson, [[ [false] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_ending_with_newline.json
|
||||
assert(true == pcall(DecodeJson, [[ ["a"] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty-string.json
|
||||
assert(true == pcall(DecodeJson, [[ [""] ]]))
|
||||
|
||||
-- https://github.com/nst/JSONTestSuite/tree/d64aefb55228d9584d3e5b2433f720ea8fd00c82/test_parsing/y_array_empty.json
|
||||
assert(true == pcall(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, [[
|
||||
[ [ ] ] ]]))
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail1.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
"A JSON payload should be an object or array, not a string."
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail10.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Extra value after close": true} "misplaced quoted value"
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail11.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Illegal expression": 1 + 2}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail12.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Illegal invocation": alert()}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail13.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Numbers cannot have leading zeroes": 013}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail14.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Numbers cannot be hex": 0x14}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail15.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Illegal backslash escape: \x15"]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail16.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ \naked]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail17.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Illegal backslash escape: \017"]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail18.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail19.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Missing colon" null}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail2.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Unclosed array"
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail20.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Double colon":: null}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail21.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Comma instead of colon", null}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail22.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Colon instead of comma": false]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail23.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Bad value", truth]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail24.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 'single quote']
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail25.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ " tab character in string "]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail26.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "tab\ character\ in\ string\ "]
|
||||
]]))
|
|
@ -1,6 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail27.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "line
|
||||
break"]
|
||||
]]))
|
|
@ -1,6 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail28.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "line\
|
||||
break"]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail29.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 0e]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail3.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{unquoted_key: "keys must be quoted"}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail30.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 0e+]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail31.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 0e+-1]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail32.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Comma instead if closing brace": true,
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail33.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "mismatch"}
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail4.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "extra comma",]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail5.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "double extra comma",,]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail6.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ , "<-- missing value"]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail7.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Comma after the close"] ,
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail8.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Extra close"] ]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail9.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Extra comma": true,}
|
||||
]]))
|
101
test/tool/net/samples/jsonorg-fail.lua
Normal file
101
test/tool/net/samples/jsonorg-fail.lua
Normal file
|
@ -0,0 +1,101 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail11.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Illegal expression": 1 + 2}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail12.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{"Illegal invocation": alert()}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail13.json
|
||||
assert(false == pcall(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, [[
|
||||
{"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, [[
|
||||
[ \naked]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail17.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Illegal backslash escape: \017"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail22.json
|
||||
assert(false == pcall(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, [[
|
||||
[ "Bad value", truth]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail24.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 'single quote']
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail29.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 0e]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail2.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ "Unclosed array"
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail30.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 0e+]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail31.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
[ 0e+-1]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail32.json
|
||||
assert(false == pcall(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, [[
|
||||
[ "mismatch"}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail3.json
|
||||
assert(false == pcall(DecodeJson, [[
|
||||
{unquoted_key: "keys must be quoted"}
|
||||
]]))
|
90
test/tool/net/samples/jsonorg-lenient.lua
Normal file
90
test/tool/net/samples/jsonorg-lenient.lua
Normal file
|
@ -0,0 +1,90 @@
|
|||
-- json.org says the following test cases should be
|
||||
-- considered as invalid JSON, but ljson.c is lenient.
|
||||
-- we run these tests anyway just to ensure that
|
||||
-- no segfaults occurs while parsing these cases
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail4.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "extra comma",]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail5.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "double extra comma",,]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail6.json
|
||||
assert(nil ~= pcall(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, [[
|
||||
{"Extra comma": true,}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail19.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
{"Missing colon" null}
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail20.json
|
||||
assert(nil ~= pcall(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, [[
|
||||
[ " 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, [[
|
||||
[ "line
|
||||
break"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail28.json
|
||||
assert(nil ~= pcall(DecodeJson, [[
|
||||
[ "line\
|
||||
break"]
|
||||
]]))
|
|
@ -60,3 +60,38 @@ assert(pcall(DecodeJson, [[
|
|||
1e00,2e+00,2e-00
|
||||
,"rosebud"]
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass2.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Not too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
|
||||
]]))
|
||||
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass3.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
{
|
||||
"JSON Test Pattern pass3": {
|
||||
"The outermost value": "must be an object or array.",
|
||||
"In this test": "It is an object."
|
||||
}
|
||||
}
|
||||
|
||||
]]))
|
||||
|
||||
|
||||
-- json.org says these should fail, but many parsers,
|
||||
-- including python's json.load allow the following
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail1.json (actually passes)
|
||||
assert(pcall(DecodeJson, [[
|
||||
"A JSON payload should be an object or array, not a string."
|
||||
]]))
|
||||
|
||||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: fail18.json (actually passes)
|
||||
assert(pcall(DecodeJson, [[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
|
||||
]]))
|
|
@ -1,5 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass2.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Not too deep"] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
|
||||
]]))
|
|
@ -1,11 +0,0 @@
|
|||
-- https://www.json.org/JSON_checker/test.zip
|
||||
-- JSON parsing sample test case: pass3.json
|
||||
assert(pcall(DecodeJson, [[
|
||||
{
|
||||
"JSON Test Pattern pass3": {
|
||||
"The outermost value": "must be an object or array.",
|
||||
"In this test": "It is an object."
|
||||
}
|
||||
}
|
||||
|
||||
]]))
|
|
@ -6,30 +6,13 @@ PKGS += TEST_TOOL_NET
|
|||
TEST_TOOL_NET = $(TOOL_NET_A_DEPS) $(TOOL_NET_A)
|
||||
TEST_TOOL_NET_A = o/$(MODE)/test/tool/net/net.a
|
||||
TEST_TOOL_NET_FILES := $(wildcard test/tool/net/*)
|
||||
TEST_TOOL_NET_JSONORG := $(wildcard test/tool/net/samples/*)
|
||||
|
||||
TEST_TOOL_NET_JSONORG_STRICT = \
|
||||
test/tool/net/samples/fail10.lua \
|
||||
test/tool/net/samples/fail19.lua \
|
||||
test/tool/net/samples/fail20.lua \
|
||||
test/tool/net/samples/fail21.lua \
|
||||
test/tool/net/samples/fail25.lua \
|
||||
test/tool/net/samples/fail26.lua \
|
||||
test/tool/net/samples/fail27.lua \
|
||||
test/tool/net/samples/fail28.lua \
|
||||
test/tool/net/samples/fail4.lua \
|
||||
test/tool/net/samples/fail5.lua \
|
||||
test/tool/net/samples/fail6.lua \
|
||||
test/tool/net/samples/fail7.lua \
|
||||
test/tool/net/samples/fail8.lua \
|
||||
test/tool/net/samples/fail9.lua
|
||||
|
||||
TEST_TOOL_NET_JSONORG_LUA = $(filter-out $(TEST_TOOL_NET_JSONORG_STRICT),$(filter %.lua,$(TEST_TOOL_NET_JSONORG)))
|
||||
TEST_TOOL_NET_SAMPLES := $(wildcard test/tool/net/samples/*)
|
||||
TEST_TOOL_NET_SAMPLES_LUA = $(filter %.lua,$(TEST_TOOL_NET_SAMPLES))
|
||||
TEST_TOOL_NET_SRCS = $(filter %.c,$(TEST_TOOL_NET_FILES))
|
||||
TEST_TOOL_NET_SRCS_TEST = $(filter %_test.c,$(TEST_TOOL_NET_SRCS))
|
||||
TEST_TOOL_NET_LUAS_TEST = \
|
||||
$(filter %_test.lua,$(TEST_TOOL_NET_FILES)) \
|
||||
$(TEST_TOOL_NET_JSONORG_LUA)
|
||||
$(TEST_TOOL_NET_SAMPLES_LUA)
|
||||
TEST_TOOL_NET_HDRS = $(filter %.h,$(TEST_TOOL_NET_FILES))
|
||||
TEST_TOOL_NET_COMS = $(TEST_TOOL_NET_SRCS:%.c=o/$(MODE)/%.com)
|
||||
|
||||
|
|
Loading…
Reference in a new issue