| author | |
| committer | |
| log | da28811c500c8fdc77468013840f978781e9ef7d |
| tree | e834e6dcd456075fa23eecc5789a10bd667b20d6 |
| parent | 4b6f350369d1a27353f521c25fd938b6232b631a |
| signature |
I think it was a mistake that these weren't getting automatically run by
the test suite.3 files changed, 1908 insertions(+), 1904 deletions(-)
std/json.zig+4| ... | ... | @@ -1400,3 +1400,7 @@ test "json.parser.dynamic" { |
| 1400 | 1400 | const double = image.Object.get("double").?.value; |
| 1401 | 1401 | testing.expect(double.Float == 1.3412); |
| 1402 | 1402 | } |
| 1403 | ||
| 1404 | test "import more json tests" { | |
| 1405 | _ = @import("json/test.zig"); | |
| 1406 | } |
std/json/test.zig created+1904| ... | ... | @@ -0,0 +1,1904 @@ |
| 1 | // RFC 8529 conformance tests. | |
| 2 | // | |
| 3 | // Tests are taken from https://github.com/nst/JSONTestSuite | |
| 4 | // Read also http://seriot.ch/parsing_json.php for a good overview. | |
| 5 | ||
| 6 | const std = @import("../std.zig"); | |
| 7 | ||
| 8 | fn ok(comptime s: []const u8) void { | |
| 9 | std.testing.expect(std.json.validate(s)); | |
| 10 | } | |
| 11 | ||
| 12 | fn err(comptime s: []const u8) void { | |
| 13 | std.testing.expect(!std.json.validate(s)); | |
| 14 | } | |
| 15 | ||
| 16 | fn any(comptime s: []const u8) void { | |
| 17 | std.testing.expect(true); | |
| 18 | } | |
| 19 | ||
| 20 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 21 | // | |
| 22 | // Additional tests not part of test JSONTestSuite. | |
| 23 | ||
| 24 | test "json.test.y_trailing_comma_after_empty" { | |
| 25 | ok( | |
| 26 | \\{"1":[],"2":{},"3":"4"} | |
| 27 | ); | |
| 28 | } | |
| 29 | ||
| 30 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 31 | ||
| 32 | test "json.test.y_array_arraysWithSpaces" { | |
| 33 | ok( | |
| 34 | \\[[] ] | |
| 35 | ); | |
| 36 | } | |
| 37 | ||
| 38 | test "json.test.y_array_empty" { | |
| 39 | ok( | |
| 40 | \\[] | |
| 41 | ); | |
| 42 | } | |
| 43 | ||
| 44 | test "json.test.y_array_empty-string" { | |
| 45 | ok( | |
| 46 | \\[""] | |
| 47 | ); | |
| 48 | } | |
| 49 | ||
| 50 | test "json.test.y_array_ending_with_newline" { | |
| 51 | ok( | |
| 52 | \\["a"] | |
| 53 | ); | |
| 54 | } | |
| 55 | ||
| 56 | test "json.test.y_array_false" { | |
| 57 | ok( | |
| 58 | \\[false] | |
| 59 | ); | |
| 60 | } | |
| 61 | ||
| 62 | test "json.test.y_array_heterogeneous" { | |
| 63 | ok( | |
| 64 | \\[null, 1, "1", {}] | |
| 65 | ); | |
| 66 | } | |
| 67 | ||
| 68 | test "json.test.y_array_null" { | |
| 69 | ok( | |
| 70 | \\[null] | |
| 71 | ); | |
| 72 | } | |
| 73 | ||
| 74 | test "json.test.y_array_with_1_and_newline" { | |
| 75 | ok( | |
| 76 | \\[1 | |
| 77 | \\] | |
| 78 | ); | |
| 79 | } | |
| 80 | ||
| 81 | test "json.test.y_array_with_leading_space" { | |
| 82 | ok( | |
| 83 | \\ [1] | |
| 84 | ); | |
| 85 | } | |
| 86 | ||
| 87 | test "json.test.y_array_with_several_null" { | |
| 88 | ok( | |
| 89 | \\[1,null,null,null,2] | |
| 90 | ); | |
| 91 | } | |
| 92 | ||
| 93 | test "json.test.y_array_with_trailing_space" { | |
| 94 | ok("[2] "); | |
| 95 | } | |
| 96 | ||
| 97 | test "json.test.y_number_0e+1" { | |
| 98 | ok( | |
| 99 | \\[0e+1] | |
| 100 | ); | |
| 101 | } | |
| 102 | ||
| 103 | test "json.test.y_number_0e1" { | |
| 104 | ok( | |
| 105 | \\[0e1] | |
| 106 | ); | |
| 107 | } | |
| 108 | ||
| 109 | test "json.test.y_number_after_space" { | |
| 110 | ok( | |
| 111 | \\[ 4] | |
| 112 | ); | |
| 113 | } | |
| 114 | ||
| 115 | test "json.test.y_number_double_close_to_zero" { | |
| 116 | ok( | |
| 117 | \\[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] | |
| 118 | ); | |
| 119 | } | |
| 120 | ||
| 121 | test "json.test.y_number_int_with_exp" { | |
| 122 | ok( | |
| 123 | \\[20e1] | |
| 124 | ); | |
| 125 | } | |
| 126 | ||
| 127 | test "json.test.y_number" { | |
| 128 | ok( | |
| 129 | \\[123e65] | |
| 130 | ); | |
| 131 | } | |
| 132 | ||
| 133 | test "json.test.y_number_minus_zero" { | |
| 134 | ok( | |
| 135 | \\[-0] | |
| 136 | ); | |
| 137 | } | |
| 138 | ||
| 139 | test "json.test.y_number_negative_int" { | |
| 140 | ok( | |
| 141 | \\[-123] | |
| 142 | ); | |
| 143 | } | |
| 144 | ||
| 145 | test "json.test.y_number_negative_one" { | |
| 146 | ok( | |
| 147 | \\[-1] | |
| 148 | ); | |
| 149 | } | |
| 150 | ||
| 151 | test "json.test.y_number_negative_zero" { | |
| 152 | ok( | |
| 153 | \\[-0] | |
| 154 | ); | |
| 155 | } | |
| 156 | ||
| 157 | test "json.test.y_number_real_capital_e" { | |
| 158 | ok( | |
| 159 | \\[1E22] | |
| 160 | ); | |
| 161 | } | |
| 162 | ||
| 163 | test "json.test.y_number_real_capital_e_neg_exp" { | |
| 164 | ok( | |
| 165 | \\[1E-2] | |
| 166 | ); | |
| 167 | } | |
| 168 | ||
| 169 | test "json.test.y_number_real_capital_e_pos_exp" { | |
| 170 | ok( | |
| 171 | \\[1E+2] | |
| 172 | ); | |
| 173 | } | |
| 174 | ||
| 175 | test "json.test.y_number_real_exponent" { | |
| 176 | ok( | |
| 177 | \\[123e45] | |
| 178 | ); | |
| 179 | } | |
| 180 | ||
| 181 | test "json.test.y_number_real_fraction_exponent" { | |
| 182 | ok( | |
| 183 | \\[123.456e78] | |
| 184 | ); | |
| 185 | } | |
| 186 | ||
| 187 | test "json.test.y_number_real_neg_exp" { | |
| 188 | ok( | |
| 189 | \\[1e-2] | |
| 190 | ); | |
| 191 | } | |
| 192 | ||
| 193 | test "json.test.y_number_real_pos_exponent" { | |
| 194 | ok( | |
| 195 | \\[1e+2] | |
| 196 | ); | |
| 197 | } | |
| 198 | ||
| 199 | test "json.test.y_number_simple_int" { | |
| 200 | ok( | |
| 201 | \\[123] | |
| 202 | ); | |
| 203 | } | |
| 204 | ||
| 205 | test "json.test.y_number_simple_real" { | |
| 206 | ok( | |
| 207 | \\[123.456789] | |
| 208 | ); | |
| 209 | } | |
| 210 | ||
| 211 | test "json.test.y_object_basic" { | |
| 212 | ok( | |
| 213 | \\{"asd":"sdf"} | |
| 214 | ); | |
| 215 | } | |
| 216 | ||
| 217 | test "json.test.y_object_duplicated_key_and_value" { | |
| 218 | ok( | |
| 219 | \\{"a":"b","a":"b"} | |
| 220 | ); | |
| 221 | } | |
| 222 | ||
| 223 | test "json.test.y_object_duplicated_key" { | |
| 224 | ok( | |
| 225 | \\{"a":"b","a":"c"} | |
| 226 | ); | |
| 227 | } | |
| 228 | ||
| 229 | test "json.test.y_object_empty" { | |
| 230 | ok( | |
| 231 | \\{} | |
| 232 | ); | |
| 233 | } | |
| 234 | ||
| 235 | test "json.test.y_object_empty_key" { | |
| 236 | ok( | |
| 237 | \\{"":0} | |
| 238 | ); | |
| 239 | } | |
| 240 | ||
| 241 | test "json.test.y_object_escaped_null_in_key" { | |
| 242 | ok( | |
| 243 | \\{"foo\u0000bar": 42} | |
| 244 | ); | |
| 245 | } | |
| 246 | ||
| 247 | test "json.test.y_object_extreme_numbers" { | |
| 248 | ok( | |
| 249 | \\{ "min": -1.0e+28, "max": 1.0e+28 } | |
| 250 | ); | |
| 251 | } | |
| 252 | ||
| 253 | test "json.test.y_object" { | |
| 254 | ok( | |
| 255 | \\{"asd":"sdf", "dfg":"fgh"} | |
| 256 | ); | |
| 257 | } | |
| 258 | ||
| 259 | test "json.test.y_object_long_strings" { | |
| 260 | ok( | |
| 261 | \\{"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} | |
| 262 | ); | |
| 263 | } | |
| 264 | ||
| 265 | test "json.test.y_object_simple" { | |
| 266 | ok( | |
| 267 | \\{"a":[]} | |
| 268 | ); | |
| 269 | } | |
| 270 | ||
| 271 | test "json.test.y_object_string_unicode" { | |
| 272 | ok( | |
| 273 | \\{"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } | |
| 274 | ); | |
| 275 | } | |
| 276 | ||
| 277 | test "json.test.y_object_with_newlines" { | |
| 278 | ok( | |
| 279 | \\{ | |
| 280 | \\"a": "b" | |
| 281 | \\} | |
| 282 | ); | |
| 283 | } | |
| 284 | ||
| 285 | test "json.test.y_string_1_2_3_bytes_UTF-8_sequences" { | |
| 286 | ok( | |
| 287 | \\["\u0060\u012a\u12AB"] | |
| 288 | ); | |
| 289 | } | |
| 290 | ||
| 291 | test "json.test.y_string_accepted_surrogate_pair" { | |
| 292 | ok( | |
| 293 | \\["\uD801\udc37"] | |
| 294 | ); | |
| 295 | } | |
| 296 | ||
| 297 | test "json.test.y_string_accepted_surrogate_pairs" { | |
| 298 | ok( | |
| 299 | \\["\ud83d\ude39\ud83d\udc8d"] | |
| 300 | ); | |
| 301 | } | |
| 302 | ||
| 303 | test "json.test.y_string_allowed_escapes" { | |
| 304 | ok( | |
| 305 | \\["\"\\\/\b\f\n\r\t"] | |
| 306 | ); | |
| 307 | } | |
| 308 | ||
| 309 | test "json.test.y_string_backslash_and_u_escaped_zero" { | |
| 310 | ok( | |
| 311 | \\["\\u0000"] | |
| 312 | ); | |
| 313 | } | |
| 314 | ||
| 315 | test "json.test.y_string_backslash_doublequotes" { | |
| 316 | ok( | |
| 317 | \\["\""] | |
| 318 | ); | |
| 319 | } | |
| 320 | ||
| 321 | test "json.test.y_string_comments" { | |
| 322 | ok( | |
| 323 | \\["a/*b*/c/*d//e"] | |
| 324 | ); | |
| 325 | } | |
| 326 | ||
| 327 | test "json.test.y_string_double_escape_a" { | |
| 328 | ok( | |
| 329 | \\["\\a"] | |
| 330 | ); | |
| 331 | } | |
| 332 | ||
| 333 | test "json.test.y_string_double_escape_n" { | |
| 334 | ok( | |
| 335 | \\["\\n"] | |
| 336 | ); | |
| 337 | } | |
| 338 | ||
| 339 | test "json.test.y_string_escaped_control_character" { | |
| 340 | ok( | |
| 341 | \\["\u0012"] | |
| 342 | ); | |
| 343 | } | |
| 344 | ||
| 345 | test "json.test.y_string_escaped_noncharacter" { | |
| 346 | ok( | |
| 347 | \\["\uFFFF"] | |
| 348 | ); | |
| 349 | } | |
| 350 | ||
| 351 | test "json.test.y_string_in_array" { | |
| 352 | ok( | |
| 353 | \\["asd"] | |
| 354 | ); | |
| 355 | } | |
| 356 | ||
| 357 | test "json.test.y_string_in_array_with_leading_space" { | |
| 358 | ok( | |
| 359 | \\[ "asd"] | |
| 360 | ); | |
| 361 | } | |
| 362 | ||
| 363 | test "json.test.y_string_last_surrogates_1_and_2" { | |
| 364 | ok( | |
| 365 | \\["\uDBFF\uDFFF"] | |
| 366 | ); | |
| 367 | } | |
| 368 | ||
| 369 | test "json.test.y_string_nbsp_uescaped" { | |
| 370 | ok( | |
| 371 | \\["new\u00A0line"] | |
| 372 | ); | |
| 373 | } | |
| 374 | ||
| 375 | test "json.test.y_string_nonCharacterInUTF-8_U+10FFFF" { | |
| 376 | ok( | |
| 377 | \\[""] | |
| 378 | ); | |
| 379 | } | |
| 380 | ||
| 381 | test "json.test.y_string_nonCharacterInUTF-8_U+FFFF" { | |
| 382 | ok( | |
| 383 | \\[""] | |
| 384 | ); | |
| 385 | } | |
| 386 | ||
| 387 | test "json.test.y_string_null_escape" { | |
| 388 | ok( | |
| 389 | \\["\u0000"] | |
| 390 | ); | |
| 391 | } | |
| 392 | ||
| 393 | test "json.test.y_string_one-byte-utf-8" { | |
| 394 | ok( | |
| 395 | \\["\u002c"] | |
| 396 | ); | |
| 397 | } | |
| 398 | ||
| 399 | test "json.test.y_string_pi" { | |
| 400 | ok( | |
| 401 | \\["π"] | |
| 402 | ); | |
| 403 | } | |
| 404 | ||
| 405 | test "json.test.y_string_reservedCharacterInUTF-8_U+1BFFF" { | |
| 406 | ok( | |
| 407 | \\[""] | |
| 408 | ); | |
| 409 | } | |
| 410 | ||
| 411 | test "json.test.y_string_simple_ascii" { | |
| 412 | ok( | |
| 413 | \\["asd "] | |
| 414 | ); | |
| 415 | } | |
| 416 | ||
| 417 | test "json.test.y_string_space" { | |
| 418 | ok( | |
| 419 | \\" " | |
| 420 | ); | |
| 421 | } | |
| 422 | ||
| 423 | test "json.test.y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF" { | |
| 424 | ok( | |
| 425 | \\["\uD834\uDd1e"] | |
| 426 | ); | |
| 427 | } | |
| 428 | ||
| 429 | test "json.test.y_string_three-byte-utf-8" { | |
| 430 | ok( | |
| 431 | \\["\u0821"] | |
| 432 | ); | |
| 433 | } | |
| 434 | ||
| 435 | test "json.test.y_string_two-byte-utf-8" { | |
| 436 | ok( | |
| 437 | \\["\u0123"] | |
| 438 | ); | |
| 439 | } | |
| 440 | ||
| 441 | test "json.test.y_string_u+2028_line_sep" { | |
| 442 | ok("[\"\xe2\x80\xa8\"]"); | |
| 443 | } | |
| 444 | ||
| 445 | test "json.test.y_string_u+2029_par_sep" { | |
| 446 | ok("[\"\xe2\x80\xa9\"]"); | |
| 447 | } | |
| 448 | ||
| 449 | test "json.test.y_string_uescaped_newline" { | |
| 450 | ok( | |
| 451 | \\["new\u000Aline"] | |
| 452 | ); | |
| 453 | } | |
| 454 | ||
| 455 | test "json.test.y_string_uEscape" { | |
| 456 | ok( | |
| 457 | \\["\u0061\u30af\u30EA\u30b9"] | |
| 458 | ); | |
| 459 | } | |
| 460 | ||
| 461 | test "json.test.y_string_unescaped_char_delete" { | |
| 462 | ok("[\"\x7f\"]"); | |
| 463 | } | |
| 464 | ||
| 465 | test "json.test.y_string_unicode_2" { | |
| 466 | ok( | |
| 467 | \\["⍂㈴⍂"] | |
| 468 | ); | |
| 469 | } | |
| 470 | ||
| 471 | test "json.test.y_string_unicodeEscapedBackslash" { | |
| 472 | ok( | |
| 473 | \\["\u005C"] | |
| 474 | ); | |
| 475 | } | |
| 476 | ||
| 477 | test "json.test.y_string_unicode_escaped_double_quote" { | |
| 478 | ok( | |
| 479 | \\["\u0022"] | |
| 480 | ); | |
| 481 | } | |
| 482 | ||
| 483 | test "json.test.y_string_unicode" { | |
| 484 | ok( | |
| 485 | \\["\uA66D"] | |
| 486 | ); | |
| 487 | } | |
| 488 | ||
| 489 | test "json.test.y_string_unicode_U+10FFFE_nonchar" { | |
| 490 | ok( | |
| 491 | \\["\uDBFF\uDFFE"] | |
| 492 | ); | |
| 493 | } | |
| 494 | ||
| 495 | test "json.test.y_string_unicode_U+1FFFE_nonchar" { | |
| 496 | ok( | |
| 497 | \\["\uD83F\uDFFE"] | |
| 498 | ); | |
| 499 | } | |
| 500 | ||
| 501 | test "json.test.y_string_unicode_U+200B_ZERO_WIDTH_SPACE" { | |
| 502 | ok( | |
| 503 | \\["\u200B"] | |
| 504 | ); | |
| 505 | } | |
| 506 | ||
| 507 | test "json.test.y_string_unicode_U+2064_invisible_plus" { | |
| 508 | ok( | |
| 509 | \\["\u2064"] | |
| 510 | ); | |
| 511 | } | |
| 512 | ||
| 513 | test "json.test.y_string_unicode_U+FDD0_nonchar" { | |
| 514 | ok( | |
| 515 | \\["\uFDD0"] | |
| 516 | ); | |
| 517 | } | |
| 518 | ||
| 519 | test "json.test.y_string_unicode_U+FFFE_nonchar" { | |
| 520 | ok( | |
| 521 | \\["\uFFFE"] | |
| 522 | ); | |
| 523 | } | |
| 524 | ||
| 525 | test "json.test.y_string_utf8" { | |
| 526 | ok( | |
| 527 | \\["€𝄞"] | |
| 528 | ); | |
| 529 | } | |
| 530 | ||
| 531 | test "json.test.y_string_with_del_character" { | |
| 532 | ok("[\"a\x7fa\"]"); | |
| 533 | } | |
| 534 | ||
| 535 | test "json.test.y_structure_lonely_false" { | |
| 536 | ok( | |
| 537 | \\false | |
| 538 | ); | |
| 539 | } | |
| 540 | ||
| 541 | test "json.test.y_structure_lonely_int" { | |
| 542 | ok( | |
| 543 | \\42 | |
| 544 | ); | |
| 545 | } | |
| 546 | ||
| 547 | test "json.test.y_structure_lonely_negative_real" { | |
| 548 | ok( | |
| 549 | \\-0.1 | |
| 550 | ); | |
| 551 | } | |
| 552 | ||
| 553 | test "json.test.y_structure_lonely_null" { | |
| 554 | ok( | |
| 555 | \\null | |
| 556 | ); | |
| 557 | } | |
| 558 | ||
| 559 | test "json.test.y_structure_lonely_string" { | |
| 560 | ok( | |
| 561 | \\"asd" | |
| 562 | ); | |
| 563 | } | |
| 564 | ||
| 565 | test "json.test.y_structure_lonely_true" { | |
| 566 | ok( | |
| 567 | \\true | |
| 568 | ); | |
| 569 | } | |
| 570 | ||
| 571 | test "json.test.y_structure_string_empty" { | |
| 572 | ok( | |
| 573 | \\"" | |
| 574 | ); | |
| 575 | } | |
| 576 | ||
| 577 | test "json.test.y_structure_trailing_newline" { | |
| 578 | ok( | |
| 579 | \\["a"] | |
| 580 | ); | |
| 581 | } | |
| 582 | ||
| 583 | test "json.test.y_structure_true_in_array" { | |
| 584 | ok( | |
| 585 | \\[true] | |
| 586 | ); | |
| 587 | } | |
| 588 | ||
| 589 | test "json.test.y_structure_whitespace_array" { | |
| 590 | ok(" [] "); | |
| 591 | } | |
| 592 | ||
| 593 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 594 | ||
| 595 | test "json.test.n_array_1_true_without_comma" { | |
| 596 | err( | |
| 597 | \\[1 true] | |
| 598 | ); | |
| 599 | } | |
| 600 | ||
| 601 | test "json.test.n_array_a_invalid_utf8" { | |
| 602 | err( | |
| 603 | \\[aå] | |
| 604 | ); | |
| 605 | } | |
| 606 | ||
| 607 | test "json.test.n_array_colon_instead_of_comma" { | |
| 608 | err( | |
| 609 | \\["": 1] | |
| 610 | ); | |
| 611 | } | |
| 612 | ||
| 613 | test "json.test.n_array_comma_after_close" { | |
| 614 | //err( | |
| 615 | // \\[""], | |
| 616 | //); | |
| 617 | } | |
| 618 | ||
| 619 | test "json.test.n_array_comma_and_number" { | |
| 620 | err( | |
| 621 | \\[,1] | |
| 622 | ); | |
| 623 | } | |
| 624 | ||
| 625 | test "json.test.n_array_double_comma" { | |
| 626 | err( | |
| 627 | \\[1,,2] | |
| 628 | ); | |
| 629 | } | |
| 630 | ||
| 631 | test "json.test.n_array_double_extra_comma" { | |
| 632 | err( | |
| 633 | \\["x",,] | |
| 634 | ); | |
| 635 | } | |
| 636 | ||
| 637 | test "json.test.n_array_extra_close" { | |
| 638 | err( | |
| 639 | \\["x"]] | |
| 640 | ); | |
| 641 | } | |
| 642 | ||
| 643 | test "json.test.n_array_extra_comma" { | |
| 644 | //err( | |
| 645 | // \\["",] | |
| 646 | //); | |
| 647 | } | |
| 648 | ||
| 649 | test "json.test.n_array_incomplete_invalid_value" { | |
| 650 | err( | |
| 651 | \\[x | |
| 652 | ); | |
| 653 | } | |
| 654 | ||
| 655 | test "json.test.n_array_incomplete" { | |
| 656 | err( | |
| 657 | \\["x" | |
| 658 | ); | |
| 659 | } | |
| 660 | ||
| 661 | test "json.test.n_array_inner_array_no_comma" { | |
| 662 | err( | |
| 663 | \\[3[4]] | |
| 664 | ); | |
| 665 | } | |
| 666 | ||
| 667 | test "json.test.n_array_invalid_utf8" { | |
| 668 | err( | |
| 669 | \\[ÿ] | |
| 670 | ); | |
| 671 | } | |
| 672 | ||
| 673 | test "json.test.n_array_items_separated_by_semicolon" { | |
| 674 | err( | |
| 675 | \\[1:2] | |
| 676 | ); | |
| 677 | } | |
| 678 | ||
| 679 | test "json.test.n_array_just_comma" { | |
| 680 | err( | |
| 681 | \\[,] | |
| 682 | ); | |
| 683 | } | |
| 684 | ||
| 685 | test "json.test.n_array_just_minus" { | |
| 686 | err( | |
| 687 | \\[-] | |
| 688 | ); | |
| 689 | } | |
| 690 | ||
| 691 | test "json.test.n_array_missing_value" { | |
| 692 | err( | |
| 693 | \\[ , ""] | |
| 694 | ); | |
| 695 | } | |
| 696 | ||
| 697 | test "json.test.n_array_newlines_unclosed" { | |
| 698 | err( | |
| 699 | \\["a", | |
| 700 | \\4 | |
| 701 | \\,1, | |
| 702 | ); | |
| 703 | } | |
| 704 | ||
| 705 | test "json.test.n_array_number_and_comma" { | |
| 706 | err( | |
| 707 | \\[1,] | |
| 708 | ); | |
| 709 | } | |
| 710 | ||
| 711 | test "json.test.n_array_number_and_several_commas" { | |
| 712 | err( | |
| 713 | \\[1,,] | |
| 714 | ); | |
| 715 | } | |
| 716 | ||
| 717 | test "json.test.n_array_spaces_vertical_tab_formfeed" { | |
| 718 | err("[\"\x0aa\"\\f]"); | |
| 719 | } | |
| 720 | ||
| 721 | test "json.test.n_array_star_inside" { | |
| 722 | err( | |
| 723 | \\[*] | |
| 724 | ); | |
| 725 | } | |
| 726 | ||
| 727 | test "json.test.n_array_unclosed" { | |
| 728 | err( | |
| 729 | \\["" | |
| 730 | ); | |
| 731 | } | |
| 732 | ||
| 733 | test "json.test.n_array_unclosed_trailing_comma" { | |
| 734 | err( | |
| 735 | \\[1, | |
| 736 | ); | |
| 737 | } | |
| 738 | ||
| 739 | test "json.test.n_array_unclosed_with_new_lines" { | |
| 740 | err( | |
| 741 | \\[1, | |
| 742 | \\1 | |
| 743 | \\,1 | |
| 744 | ); | |
| 745 | } | |
| 746 | ||
| 747 | test "json.test.n_array_unclosed_with_object_inside" { | |
| 748 | err( | |
| 749 | \\[{} | |
| 750 | ); | |
| 751 | } | |
| 752 | ||
| 753 | test "json.test.n_incomplete_false" { | |
| 754 | err( | |
| 755 | \\[fals] | |
| 756 | ); | |
| 757 | } | |
| 758 | ||
| 759 | test "json.test.n_incomplete_null" { | |
| 760 | err( | |
| 761 | \\[nul] | |
| 762 | ); | |
| 763 | } | |
| 764 | ||
| 765 | test "json.test.n_incomplete_true" { | |
| 766 | err( | |
| 767 | \\[tru] | |
| 768 | ); | |
| 769 | } | |
| 770 | ||
| 771 | test "json.test.n_multidigit_number_then_00" { | |
| 772 | err("123\x00"); | |
| 773 | } | |
| 774 | ||
| 775 | test "json.test.n_number_0.1.2" { | |
| 776 | err( | |
| 777 | \\[0.1.2] | |
| 778 | ); | |
| 779 | } | |
| 780 | ||
| 781 | test "json.test.n_number_-01" { | |
| 782 | err( | |
| 783 | \\[-01] | |
| 784 | ); | |
| 785 | } | |
| 786 | ||
| 787 | test "json.test.n_number_0.3e" { | |
| 788 | err( | |
| 789 | \\[0.3e] | |
| 790 | ); | |
| 791 | } | |
| 792 | ||
| 793 | test "json.test.n_number_0.3e+" { | |
| 794 | err( | |
| 795 | \\[0.3e+] | |
| 796 | ); | |
| 797 | } | |
| 798 | ||
| 799 | test "json.test.n_number_0_capital_E" { | |
| 800 | err( | |
| 801 | \\[0E] | |
| 802 | ); | |
| 803 | } | |
| 804 | ||
| 805 | test "json.test.n_number_0_capital_E+" { | |
| 806 | err( | |
| 807 | \\[0E+] | |
| 808 | ); | |
| 809 | } | |
| 810 | ||
| 811 | test "json.test.n_number_0.e1" { | |
| 812 | err( | |
| 813 | \\[0.e1] | |
| 814 | ); | |
| 815 | } | |
| 816 | ||
| 817 | test "json.test.n_number_0e" { | |
| 818 | err( | |
| 819 | \\[0e] | |
| 820 | ); | |
| 821 | } | |
| 822 | ||
| 823 | test "json.test.n_number_0e+" { | |
| 824 | err( | |
| 825 | \\[0e+] | |
| 826 | ); | |
| 827 | } | |
| 828 | ||
| 829 | test "json.test.n_number_1_000" { | |
| 830 | err( | |
| 831 | \\[1 000.0] | |
| 832 | ); | |
| 833 | } | |
| 834 | ||
| 835 | test "json.test.n_number_1.0e-" { | |
| 836 | err( | |
| 837 | \\[1.0e-] | |
| 838 | ); | |
| 839 | } | |
| 840 | ||
| 841 | test "json.test.n_number_1.0e" { | |
| 842 | err( | |
| 843 | \\[1.0e] | |
| 844 | ); | |
| 845 | } | |
| 846 | ||
| 847 | test "json.test.n_number_1.0e+" { | |
| 848 | err( | |
| 849 | \\[1.0e+] | |
| 850 | ); | |
| 851 | } | |
| 852 | ||
| 853 | test "json.test.n_number_-1.0." { | |
| 854 | err( | |
| 855 | \\[-1.0.] | |
| 856 | ); | |
| 857 | } | |
| 858 | ||
| 859 | test "json.test.n_number_1eE2" { | |
| 860 | err( | |
| 861 | \\[1eE2] | |
| 862 | ); | |
| 863 | } | |
| 864 | ||
| 865 | test "json.test.n_number_.-1" { | |
| 866 | err( | |
| 867 | \\[.-1] | |
| 868 | ); | |
| 869 | } | |
| 870 | ||
| 871 | test "json.test.n_number_+1" { | |
| 872 | err( | |
| 873 | \\[+1] | |
| 874 | ); | |
| 875 | } | |
| 876 | ||
| 877 | test "json.test.n_number_.2e-3" { | |
| 878 | err( | |
| 879 | \\[.2e-3] | |
| 880 | ); | |
| 881 | } | |
| 882 | ||
| 883 | test "json.test.n_number_2.e-3" { | |
| 884 | err( | |
| 885 | \\[2.e-3] | |
| 886 | ); | |
| 887 | } | |
| 888 | ||
| 889 | test "json.test.n_number_2.e+3" { | |
| 890 | err( | |
| 891 | \\[2.e+3] | |
| 892 | ); | |
| 893 | } | |
| 894 | ||
| 895 | test "json.test.n_number_2.e3" { | |
| 896 | err( | |
| 897 | \\[2.e3] | |
| 898 | ); | |
| 899 | } | |
| 900 | ||
| 901 | test "json.test.n_number_-2." { | |
| 902 | err( | |
| 903 | \\[-2.] | |
| 904 | ); | |
| 905 | } | |
| 906 | ||
| 907 | test "json.test.n_number_9.e+" { | |
| 908 | err( | |
| 909 | \\[9.e+] | |
| 910 | ); | |
| 911 | } | |
| 912 | ||
| 913 | test "json.test.n_number_expression" { | |
| 914 | err( | |
| 915 | \\[1+2] | |
| 916 | ); | |
| 917 | } | |
| 918 | ||
| 919 | test "json.test.n_number_hex_1_digit" { | |
| 920 | err( | |
| 921 | \\[0x1] | |
| 922 | ); | |
| 923 | } | |
| 924 | ||
| 925 | test "json.test.n_number_hex_2_digits" { | |
| 926 | err( | |
| 927 | \\[0x42] | |
| 928 | ); | |
| 929 | } | |
| 930 | ||
| 931 | test "json.test.n_number_infinity" { | |
| 932 | err( | |
| 933 | \\[Infinity] | |
| 934 | ); | |
| 935 | } | |
| 936 | ||
| 937 | test "json.test.n_number_+Inf" { | |
| 938 | err( | |
| 939 | \\[+Inf] | |
| 940 | ); | |
| 941 | } | |
| 942 | ||
| 943 | test "json.test.n_number_Inf" { | |
| 944 | err( | |
| 945 | \\[Inf] | |
| 946 | ); | |
| 947 | } | |
| 948 | ||
| 949 | test "json.test.n_number_invalid+-" { | |
| 950 | err( | |
| 951 | \\[0e+-1] | |
| 952 | ); | |
| 953 | } | |
| 954 | ||
| 955 | test "json.test.n_number_invalid-negative-real" { | |
| 956 | err( | |
| 957 | \\[-123.123foo] | |
| 958 | ); | |
| 959 | } | |
| 960 | ||
| 961 | test "json.test.n_number_invalid-utf-8-in-bigger-int" { | |
| 962 | err( | |
| 963 | \\[123å] | |
| 964 | ); | |
| 965 | } | |
| 966 | ||
| 967 | test "json.test.n_number_invalid-utf-8-in-exponent" { | |
| 968 | err( | |
| 969 | \\[1e1å] | |
| 970 | ); | |
| 971 | } | |
| 972 | ||
| 973 | test "json.test.n_number_invalid-utf-8-in-int" { | |
| 974 | err( | |
| 975 | \\[0å] | |
| 976 | ); | |
| 977 | } | |
| 978 | ||
| 979 | test "json.test.n_number_++" { | |
| 980 | err( | |
| 981 | \\[++1234] | |
| 982 | ); | |
| 983 | } | |
| 984 | ||
| 985 | test "json.test.n_number_minus_infinity" { | |
| 986 | err( | |
| 987 | \\[-Infinity] | |
| 988 | ); | |
| 989 | } | |
| 990 | ||
| 991 | test "json.test.n_number_minus_sign_with_trailing_garbage" { | |
| 992 | err( | |
| 993 | \\[-foo] | |
| 994 | ); | |
| 995 | } | |
| 996 | ||
| 997 | test "json.test.n_number_minus_space_1" { | |
| 998 | err( | |
| 999 | \\[- 1] | |
| 1000 | ); | |
| 1001 | } | |
| 1002 | ||
| 1003 | test "json.test.n_number_-NaN" { | |
| 1004 | err( | |
| 1005 | \\[-NaN] | |
| 1006 | ); | |
| 1007 | } | |
| 1008 | ||
| 1009 | test "json.test.n_number_NaN" { | |
| 1010 | err( | |
| 1011 | \\[NaN] | |
| 1012 | ); | |
| 1013 | } | |
| 1014 | ||
| 1015 | test "json.test.n_number_neg_int_starting_with_zero" { | |
| 1016 | err( | |
| 1017 | \\[-012] | |
| 1018 | ); | |
| 1019 | } | |
| 1020 | ||
| 1021 | test "json.test.n_number_neg_real_without_int_part" { | |
| 1022 | err( | |
| 1023 | \\[-.123] | |
| 1024 | ); | |
| 1025 | } | |
| 1026 | ||
| 1027 | test "json.test.n_number_neg_with_garbage_at_end" { | |
| 1028 | err( | |
| 1029 | \\[-1x] | |
| 1030 | ); | |
| 1031 | } | |
| 1032 | ||
| 1033 | test "json.test.n_number_real_garbage_after_e" { | |
| 1034 | err( | |
| 1035 | \\[1ea] | |
| 1036 | ); | |
| 1037 | } | |
| 1038 | ||
| 1039 | test "json.test.n_number_real_with_invalid_utf8_after_e" { | |
| 1040 | err( | |
| 1041 | \\[1eå] | |
| 1042 | ); | |
| 1043 | } | |
| 1044 | ||
| 1045 | test "json.test.n_number_real_without_fractional_part" { | |
| 1046 | err( | |
| 1047 | \\[1.] | |
| 1048 | ); | |
| 1049 | } | |
| 1050 | ||
| 1051 | test "json.test.n_number_starting_with_dot" { | |
| 1052 | err( | |
| 1053 | \\[.123] | |
| 1054 | ); | |
| 1055 | } | |
| 1056 | ||
| 1057 | test "json.test.n_number_U+FF11_fullwidth_digit_one" { | |
| 1058 | err( | |
| 1059 | \\[ï¼] | |
| 1060 | ); | |
| 1061 | } | |
| 1062 | ||
| 1063 | test "json.test.n_number_with_alpha_char" { | |
| 1064 | err( | |
| 1065 | \\[1.8011670033376514H-308] | |
| 1066 | ); | |
| 1067 | } | |
| 1068 | ||
| 1069 | test "json.test.n_number_with_alpha" { | |
| 1070 | err( | |
| 1071 | \\[1.2a-3] | |
| 1072 | ); | |
| 1073 | } | |
| 1074 | ||
| 1075 | test "json.test.n_number_with_leading_zero" { | |
| 1076 | err( | |
| 1077 | \\[012] | |
| 1078 | ); | |
| 1079 | } | |
| 1080 | ||
| 1081 | test "json.test.n_object_bad_value" { | |
| 1082 | err( | |
| 1083 | \\["x", truth] | |
| 1084 | ); | |
| 1085 | } | |
| 1086 | ||
| 1087 | test "json.test.n_object_bracket_key" { | |
| 1088 | err( | |
| 1089 | \\{[: "x"} | |
| 1090 | ); | |
| 1091 | } | |
| 1092 | ||
| 1093 | test "json.test.n_object_comma_instead_of_colon" { | |
| 1094 | err( | |
| 1095 | \\{"x", null} | |
| 1096 | ); | |
| 1097 | } | |
| 1098 | ||
| 1099 | test "json.test.n_object_double_colon" { | |
| 1100 | err( | |
| 1101 | \\{"x"::"b"} | |
| 1102 | ); | |
| 1103 | } | |
| 1104 | ||
| 1105 | test "json.test.n_object_emoji" { | |
| 1106 | err( | |
| 1107 | \\{ð¨ð} | |
| 1108 | ); | |
| 1109 | } | |
| 1110 | ||
| 1111 | test "json.test.n_object_garbage_at_end" { | |
| 1112 | err( | |
| 1113 | \\{"a":"a" 123} | |
| 1114 | ); | |
| 1115 | } | |
| 1116 | ||
| 1117 | test "json.test.n_object_key_with_single_quotes" { | |
| 1118 | err( | |
| 1119 | \\{key: 'value'} | |
| 1120 | ); | |
| 1121 | } | |
| 1122 | ||
| 1123 | test "json.test.n_object_lone_continuation_byte_in_key_and_trailing_comma" { | |
| 1124 | err( | |
| 1125 | \\{"¹":"0",} | |
| 1126 | ); | |
| 1127 | } | |
| 1128 | ||
| 1129 | test "json.test.n_object_missing_colon" { | |
| 1130 | err( | |
| 1131 | \\{"a" b} | |
| 1132 | ); | |
| 1133 | } | |
| 1134 | ||
| 1135 | test "json.test.n_object_missing_key" { | |
| 1136 | err( | |
| 1137 | \\{:"b"} | |
| 1138 | ); | |
| 1139 | } | |
| 1140 | ||
| 1141 | test "json.test.n_object_missing_semicolon" { | |
| 1142 | err( | |
| 1143 | \\{"a" "b"} | |
| 1144 | ); | |
| 1145 | } | |
| 1146 | ||
| 1147 | test "json.test.n_object_missing_value" { | |
| 1148 | err( | |
| 1149 | \\{"a": | |
| 1150 | ); | |
| 1151 | } | |
| 1152 | ||
| 1153 | test "json.test.n_object_no-colon" { | |
| 1154 | err( | |
| 1155 | \\{"a" | |
| 1156 | ); | |
| 1157 | } | |
| 1158 | ||
| 1159 | test "json.test.n_object_non_string_key_but_huge_number_instead" { | |
| 1160 | err( | |
| 1161 | \\{9999E9999:1} | |
| 1162 | ); | |
| 1163 | } | |
| 1164 | ||
| 1165 | test "json.test.n_object_non_string_key" { | |
| 1166 | err( | |
| 1167 | \\{1:1} | |
| 1168 | ); | |
| 1169 | } | |
| 1170 | ||
| 1171 | test "json.test.n_object_repeated_null_null" { | |
| 1172 | err( | |
| 1173 | \\{null:null,null:null} | |
| 1174 | ); | |
| 1175 | } | |
| 1176 | ||
| 1177 | test "json.test.n_object_several_trailing_commas" { | |
| 1178 | err( | |
| 1179 | \\{"id":0,,,,,} | |
| 1180 | ); | |
| 1181 | } | |
| 1182 | ||
| 1183 | test "json.test.n_object_single_quote" { | |
| 1184 | err( | |
| 1185 | \\{'a':0} | |
| 1186 | ); | |
| 1187 | } | |
| 1188 | ||
| 1189 | test "json.test.n_object_trailing_comma" { | |
| 1190 | err( | |
| 1191 | \\{"id":0,} | |
| 1192 | ); | |
| 1193 | } | |
| 1194 | ||
| 1195 | test "json.test.n_object_trailing_comment" { | |
| 1196 | err( | |
| 1197 | \\{"a":"b"}/**/ | |
| 1198 | ); | |
| 1199 | } | |
| 1200 | ||
| 1201 | test "json.test.n_object_trailing_comment_open" { | |
| 1202 | err( | |
| 1203 | \\{"a":"b"}/**// | |
| 1204 | ); | |
| 1205 | } | |
| 1206 | ||
| 1207 | test "json.test.n_object_trailing_comment_slash_open_incomplete" { | |
| 1208 | err( | |
| 1209 | \\{"a":"b"}/ | |
| 1210 | ); | |
| 1211 | } | |
| 1212 | ||
| 1213 | test "json.test.n_object_trailing_comment_slash_open" { | |
| 1214 | err( | |
| 1215 | \\{"a":"b"}// | |
| 1216 | ); | |
| 1217 | } | |
| 1218 | ||
| 1219 | test "json.test.n_object_two_commas_in_a_row" { | |
| 1220 | err( | |
| 1221 | \\{"a":"b",,"c":"d"} | |
| 1222 | ); | |
| 1223 | } | |
| 1224 | ||
| 1225 | test "json.test.n_object_unquoted_key" { | |
| 1226 | err( | |
| 1227 | \\{a: "b"} | |
| 1228 | ); | |
| 1229 | } | |
| 1230 | ||
| 1231 | test "json.test.n_object_unterminated-value" { | |
| 1232 | err( | |
| 1233 | \\{"a":"a | |
| 1234 | ); | |
| 1235 | } | |
| 1236 | ||
| 1237 | test "json.test.n_object_with_single_string" { | |
| 1238 | err( | |
| 1239 | \\{ "foo" : "bar", "a" } | |
| 1240 | ); | |
| 1241 | } | |
| 1242 | ||
| 1243 | test "json.test.n_object_with_trailing_garbage" { | |
| 1244 | err( | |
| 1245 | \\{"a":"b"}# | |
| 1246 | ); | |
| 1247 | } | |
| 1248 | ||
| 1249 | test "json.test.n_single_space" { | |
| 1250 | err(" "); | |
| 1251 | } | |
| 1252 | ||
| 1253 | test "json.test.n_string_1_surrogate_then_escape" { | |
| 1254 | err( | |
| 1255 | \\["\uD800\"] | |
| 1256 | ); | |
| 1257 | } | |
| 1258 | ||
| 1259 | test "json.test.n_string_1_surrogate_then_escape_u1" { | |
| 1260 | err( | |
| 1261 | \\["\uD800\u1"] | |
| 1262 | ); | |
| 1263 | } | |
| 1264 | ||
| 1265 | test "json.test.n_string_1_surrogate_then_escape_u1x" { | |
| 1266 | err( | |
| 1267 | \\["\uD800\u1x"] | |
| 1268 | ); | |
| 1269 | } | |
| 1270 | ||
| 1271 | test "json.test.n_string_1_surrogate_then_escape_u" { | |
| 1272 | err( | |
| 1273 | \\["\uD800\u"] | |
| 1274 | ); | |
| 1275 | } | |
| 1276 | ||
| 1277 | test "json.test.n_string_accentuated_char_no_quotes" { | |
| 1278 | err( | |
| 1279 | \\[é] | |
| 1280 | ); | |
| 1281 | } | |
| 1282 | ||
| 1283 | test "json.test.n_string_backslash_00" { | |
| 1284 | err("[\"\x00\"]"); | |
| 1285 | } | |
| 1286 | ||
| 1287 | test "json.test.n_string_escaped_backslash_bad" { | |
| 1288 | err( | |
| 1289 | \\["\\\"] | |
| 1290 | ); | |
| 1291 | } | |
| 1292 | ||
| 1293 | test "json.test.n_string_escaped_ctrl_char_tab" { | |
| 1294 | err("\x5b\x22\x5c\x09\x22\x5d"); | |
| 1295 | } | |
| 1296 | ||
| 1297 | test "json.test.n_string_escaped_emoji" { | |
| 1298 | err("[\"\x5c\xc3\xb0\xc2\x9f\xc2\x8c\xc2\x80\"]"); | |
| 1299 | } | |
| 1300 | ||
| 1301 | test "json.test.n_string_escape_x" { | |
| 1302 | err( | |
| 1303 | \\["\x00"] | |
| 1304 | ); | |
| 1305 | } | |
| 1306 | ||
| 1307 | test "json.test.n_string_incomplete_escaped_character" { | |
| 1308 | err( | |
| 1309 | \\["\u00A"] | |
| 1310 | ); | |
| 1311 | } | |
| 1312 | ||
| 1313 | test "json.test.n_string_incomplete_escape" { | |
| 1314 | err( | |
| 1315 | \\["\"] | |
| 1316 | ); | |
| 1317 | } | |
| 1318 | ||
| 1319 | test "json.test.n_string_incomplete_surrogate_escape_invalid" { | |
| 1320 | err( | |
| 1321 | \\["\uD800\uD800\x"] | |
| 1322 | ); | |
| 1323 | } | |
| 1324 | ||
| 1325 | test "json.test.n_string_incomplete_surrogate" { | |
| 1326 | err( | |
| 1327 | \\["\uD834\uDd"] | |
| 1328 | ); | |
| 1329 | } | |
| 1330 | ||
| 1331 | test "json.test.n_string_invalid_backslash_esc" { | |
| 1332 | err( | |
| 1333 | \\["\a"] | |
| 1334 | ); | |
| 1335 | } | |
| 1336 | ||
| 1337 | test "json.test.n_string_invalid_unicode_escape" { | |
| 1338 | err( | |
| 1339 | \\["\uqqqq"] | |
| 1340 | ); | |
| 1341 | } | |
| 1342 | ||
| 1343 | test "json.test.n_string_invalid_utf8_after_escape" { | |
| 1344 | err("[\"\\\x75\xc3\xa5\"]"); | |
| 1345 | } | |
| 1346 | ||
| 1347 | test "json.test.n_string_invalid-utf-8-in-escape" { | |
| 1348 | err( | |
| 1349 | \\["\uå"] | |
| 1350 | ); | |
| 1351 | } | |
| 1352 | ||
| 1353 | test "json.test.n_string_leading_uescaped_thinspace" { | |
| 1354 | err( | |
| 1355 | \\[\u0020"asd"] | |
| 1356 | ); | |
| 1357 | } | |
| 1358 | ||
| 1359 | test "json.test.n_string_no_quotes_with_bad_escape" { | |
| 1360 | err( | |
| 1361 | \\[\n] | |
| 1362 | ); | |
| 1363 | } | |
| 1364 | ||
| 1365 | test "json.test.n_string_single_doublequote" { | |
| 1366 | err( | |
| 1367 | \\" | |
| 1368 | ); | |
| 1369 | } | |
| 1370 | ||
| 1371 | test "json.test.n_string_single_quote" { | |
| 1372 | err( | |
| 1373 | \\['single quote'] | |
| 1374 | ); | |
| 1375 | } | |
| 1376 | ||
| 1377 | test "json.test.n_string_single_string_no_double_quotes" { | |
| 1378 | err( | |
| 1379 | \\abc | |
| 1380 | ); | |
| 1381 | } | |
| 1382 | ||
| 1383 | test "json.test.n_string_start_escape_unclosed" { | |
| 1384 | err( | |
| 1385 | \\["\ | |
| 1386 | ); | |
| 1387 | } | |
| 1388 | ||
| 1389 | test "json.test.n_string_unescaped_crtl_char" { | |
| 1390 | err("[\"a\x00a\"]"); | |
| 1391 | } | |
| 1392 | ||
| 1393 | test "json.test.n_string_unescaped_newline" { | |
| 1394 | err( | |
| 1395 | \\["new | |
| 1396 | \\line"] | |
| 1397 | ); | |
| 1398 | } | |
| 1399 | ||
| 1400 | test "json.test.n_string_unescaped_tab" { | |
| 1401 | err("[\"\t\"]"); | |
| 1402 | } | |
| 1403 | ||
| 1404 | test "json.test.n_string_unicode_CapitalU" { | |
| 1405 | err( | |
| 1406 | \\"\UA66D" | |
| 1407 | ); | |
| 1408 | } | |
| 1409 | ||
| 1410 | test "json.test.n_string_with_trailing_garbage" { | |
| 1411 | err( | |
| 1412 | \\""x | |
| 1413 | ); | |
| 1414 | } | |
| 1415 | ||
| 1416 | test "json.test.n_structure_100000_opening_arrays" { | |
| 1417 | err("[" ** 100000); | |
| 1418 | } | |
| 1419 | ||
| 1420 | test "json.test.n_structure_angle_bracket_." { | |
| 1421 | err( | |
| 1422 | \\<.> | |
| 1423 | ); | |
| 1424 | } | |
| 1425 | ||
| 1426 | test "json.test.n_structure_angle_bracket_null" { | |
| 1427 | err( | |
| 1428 | \\[<null>] | |
| 1429 | ); | |
| 1430 | } | |
| 1431 | ||
| 1432 | test "json.test.n_structure_array_trailing_garbage" { | |
| 1433 | err( | |
| 1434 | \\[1]x | |
| 1435 | ); | |
| 1436 | } | |
| 1437 | ||
| 1438 | test "json.test.n_structure_array_with_extra_array_close" { | |
| 1439 | err( | |
| 1440 | \\[1]] | |
| 1441 | ); | |
| 1442 | } | |
| 1443 | ||
| 1444 | test "json.test.n_structure_array_with_unclosed_string" { | |
| 1445 | err( | |
| 1446 | \\["asd] | |
| 1447 | ); | |
| 1448 | } | |
| 1449 | ||
| 1450 | test "json.test.n_structure_ascii-unicode-identifier" { | |
| 1451 | err( | |
| 1452 | \\aå | |
| 1453 | ); | |
| 1454 | } | |
| 1455 | ||
| 1456 | test "json.test.n_structure_capitalized_True" { | |
| 1457 | err( | |
| 1458 | \\[True] | |
| 1459 | ); | |
| 1460 | } | |
| 1461 | ||
| 1462 | test "json.test.n_structure_close_unopened_array" { | |
| 1463 | err( | |
| 1464 | \\1] | |
| 1465 | ); | |
| 1466 | } | |
| 1467 | ||
| 1468 | test "json.test.n_structure_comma_instead_of_closing_brace" { | |
| 1469 | err( | |
| 1470 | \\{"x": true, | |
| 1471 | ); | |
| 1472 | } | |
| 1473 | ||
| 1474 | test "json.test.n_structure_double_array" { | |
| 1475 | err( | |
| 1476 | \\[][] | |
| 1477 | ); | |
| 1478 | } | |
| 1479 | ||
| 1480 | test "json.test.n_structure_end_array" { | |
| 1481 | err( | |
| 1482 | \\] | |
| 1483 | ); | |
| 1484 | } | |
| 1485 | ||
| 1486 | test "json.test.n_structure_incomplete_UTF8_BOM" { | |
| 1487 | err( | |
| 1488 | \\ï»{} | |
| 1489 | ); | |
| 1490 | } | |
| 1491 | ||
| 1492 | test "json.test.n_structure_lone-invalid-utf-8" { | |
| 1493 | err( | |
| 1494 | \\å | |
| 1495 | ); | |
| 1496 | } | |
| 1497 | ||
| 1498 | test "json.test.n_structure_lone-open-bracket" { | |
| 1499 | err( | |
| 1500 | \\[ | |
| 1501 | ); | |
| 1502 | } | |
| 1503 | ||
| 1504 | test "json.test.n_structure_no_data" { | |
| 1505 | err( | |
| 1506 | \\ | |
| 1507 | ); | |
| 1508 | } | |
| 1509 | ||
| 1510 | test "json.test.n_structure_null-byte-outside-string" { | |
| 1511 | err("[\x00]"); | |
| 1512 | } | |
| 1513 | ||
| 1514 | test "json.test.n_structure_number_with_trailing_garbage" { | |
| 1515 | err( | |
| 1516 | \\2@ | |
| 1517 | ); | |
| 1518 | } | |
| 1519 | ||
| 1520 | test "json.test.n_structure_object_followed_by_closing_object" { | |
| 1521 | err( | |
| 1522 | \\{}} | |
| 1523 | ); | |
| 1524 | } | |
| 1525 | ||
| 1526 | test "json.test.n_structure_object_unclosed_no_value" { | |
| 1527 | err( | |
| 1528 | \\{"": | |
| 1529 | ); | |
| 1530 | } | |
| 1531 | ||
| 1532 | test "json.test.n_structure_object_with_comment" { | |
| 1533 | err( | |
| 1534 | \\{"a":/*comment*/"b"} | |
| 1535 | ); | |
| 1536 | } | |
| 1537 | ||
| 1538 | test "json.test.n_structure_object_with_trailing_garbage" { | |
| 1539 | err( | |
| 1540 | \\{"a": true} "x" | |
| 1541 | ); | |
| 1542 | } | |
| 1543 | ||
| 1544 | test "json.test.n_structure_open_array_apostrophe" { | |
| 1545 | err( | |
| 1546 | \\[' | |
| 1547 | ); | |
| 1548 | } | |
| 1549 | ||
| 1550 | test "json.test.n_structure_open_array_comma" { | |
| 1551 | err( | |
| 1552 | \\[, | |
| 1553 | ); | |
| 1554 | } | |
| 1555 | ||
| 1556 | test "json.test.n_structure_open_array_object" { | |
| 1557 | err("[{\"\":" ** 50000); | |
| 1558 | } | |
| 1559 | ||
| 1560 | test "json.test.n_structure_open_array_open_object" { | |
| 1561 | err( | |
| 1562 | \\[{ | |
| 1563 | ); | |
| 1564 | } | |
| 1565 | ||
| 1566 | test "json.test.n_structure_open_array_open_string" { | |
| 1567 | err( | |
| 1568 | \\["a | |
| 1569 | ); | |
| 1570 | } | |
| 1571 | ||
| 1572 | test "json.test.n_structure_open_array_string" { | |
| 1573 | err( | |
| 1574 | \\["a" | |
| 1575 | ); | |
| 1576 | } | |
| 1577 | ||
| 1578 | test "json.test.n_structure_open_object_close_array" { | |
| 1579 | err( | |
| 1580 | \\{] | |
| 1581 | ); | |
| 1582 | } | |
| 1583 | ||
| 1584 | test "json.test.n_structure_open_object_comma" { | |
| 1585 | err( | |
| 1586 | \\{, | |
| 1587 | ); | |
| 1588 | } | |
| 1589 | ||
| 1590 | test "json.test.n_structure_open_object" { | |
| 1591 | err( | |
| 1592 | \\{ | |
| 1593 | ); | |
| 1594 | } | |
| 1595 | ||
| 1596 | test "json.test.n_structure_open_object_open_array" { | |
| 1597 | err( | |
| 1598 | \\{[ | |
| 1599 | ); | |
| 1600 | } | |
| 1601 | ||
| 1602 | test "json.test.n_structure_open_object_open_string" { | |
| 1603 | err( | |
| 1604 | \\{"a | |
| 1605 | ); | |
| 1606 | } | |
| 1607 | ||
| 1608 | test "json.test.n_structure_open_object_string_with_apostrophes" { | |
| 1609 | err( | |
| 1610 | \\{'a' | |
| 1611 | ); | |
| 1612 | } | |
| 1613 | ||
| 1614 | test "json.test.n_structure_open_open" { | |
| 1615 | err( | |
| 1616 | \\["\{["\{["\{["\{ | |
| 1617 | ); | |
| 1618 | } | |
| 1619 | ||
| 1620 | test "json.test.n_structure_single_eacute" { | |
| 1621 | err( | |
| 1622 | \\é | |
| 1623 | ); | |
| 1624 | } | |
| 1625 | ||
| 1626 | test "json.test.n_structure_single_star" { | |
| 1627 | err( | |
| 1628 | \\* | |
| 1629 | ); | |
| 1630 | } | |
| 1631 | ||
| 1632 | test "json.test.n_structure_trailing_#" { | |
| 1633 | err( | |
| 1634 | \\{"a":"b"}#{} | |
| 1635 | ); | |
| 1636 | } | |
| 1637 | ||
| 1638 | test "json.test.n_structure_U+2060_word_joined" { | |
| 1639 | err( | |
| 1640 | \\[â ] | |
| 1641 | ); | |
| 1642 | } | |
| 1643 | ||
| 1644 | test "json.test.n_structure_uescaped_LF_before_string" { | |
| 1645 | err( | |
| 1646 | \\[\u000A""] | |
| 1647 | ); | |
| 1648 | } | |
| 1649 | ||
| 1650 | test "json.test.n_structure_unclosed_array" { | |
| 1651 | err( | |
| 1652 | \\[1 | |
| 1653 | ); | |
| 1654 | } | |
| 1655 | ||
| 1656 | test "json.test.n_structure_unclosed_array_partial_null" { | |
| 1657 | err( | |
| 1658 | \\[ false, nul | |
| 1659 | ); | |
| 1660 | } | |
| 1661 | ||
| 1662 | test "json.test.n_structure_unclosed_array_unfinished_false" { | |
| 1663 | err( | |
| 1664 | \\[ true, fals | |
| 1665 | ); | |
| 1666 | } | |
| 1667 | ||
| 1668 | test "json.test.n_structure_unclosed_array_unfinished_true" { | |
| 1669 | err( | |
| 1670 | \\[ false, tru | |
| 1671 | ); | |
| 1672 | } | |
| 1673 | ||
| 1674 | test "json.test.n_structure_unclosed_object" { | |
| 1675 | err( | |
| 1676 | \\{"asd":"asd" | |
| 1677 | ); | |
| 1678 | } | |
| 1679 | ||
| 1680 | test "json.test.n_structure_unicode-identifier" { | |
| 1681 | err( | |
| 1682 | \\Ã¥ | |
| 1683 | ); | |
| 1684 | } | |
| 1685 | ||
| 1686 | test "json.test.n_structure_UTF8_BOM_no_data" { | |
| 1687 | err( | |
| 1688 | \\ | |
| 1689 | ); | |
| 1690 | } | |
| 1691 | ||
| 1692 | test "json.test.n_structure_whitespace_formfeed" { | |
| 1693 | err("[\x0c]"); | |
| 1694 | } | |
| 1695 | ||
| 1696 | test "json.test.n_structure_whitespace_U+2060_word_joiner" { | |
| 1697 | err( | |
| 1698 | \\[â ] | |
| 1699 | ); | |
| 1700 | } | |
| 1701 | ||
| 1702 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 1703 | ||
| 1704 | test "json.test.i_number_double_huge_neg_exp" { | |
| 1705 | any( | |
| 1706 | \\[123.456e-789] | |
| 1707 | ); | |
| 1708 | } | |
| 1709 | ||
| 1710 | test "json.test.i_number_huge_exp" { | |
| 1711 | any( | |
| 1712 | \\[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006] | |
| 1713 | ); | |
| 1714 | } | |
| 1715 | ||
| 1716 | test "json.test.i_number_neg_int_huge_exp" { | |
| 1717 | any( | |
| 1718 | \\[-1e+9999] | |
| 1719 | ); | |
| 1720 | } | |
| 1721 | ||
| 1722 | test "json.test.i_number_pos_double_huge_exp" { | |
| 1723 | any( | |
| 1724 | \\[1.5e+9999] | |
| 1725 | ); | |
| 1726 | } | |
| 1727 | ||
| 1728 | test "json.test.i_number_real_neg_overflow" { | |
| 1729 | any( | |
| 1730 | \\[-123123e100000] | |
| 1731 | ); | |
| 1732 | } | |
| 1733 | ||
| 1734 | test "json.test.i_number_real_pos_overflow" { | |
| 1735 | any( | |
| 1736 | \\[123123e100000] | |
| 1737 | ); | |
| 1738 | } | |
| 1739 | ||
| 1740 | test "json.test.i_number_real_underflow" { | |
| 1741 | any( | |
| 1742 | \\[123e-10000000] | |
| 1743 | ); | |
| 1744 | } | |
| 1745 | ||
| 1746 | test "json.test.i_number_too_big_neg_int" { | |
| 1747 | any( | |
| 1748 | \\[-123123123123123123123123123123] | |
| 1749 | ); | |
| 1750 | } | |
| 1751 | ||
| 1752 | test "json.test.i_number_too_big_pos_int" { | |
| 1753 | any( | |
| 1754 | \\[100000000000000000000] | |
| 1755 | ); | |
| 1756 | } | |
| 1757 | ||
| 1758 | test "json.test.i_number_very_big_negative_int" { | |
| 1759 | any( | |
| 1760 | \\[-237462374673276894279832749832423479823246327846] | |
| 1761 | ); | |
| 1762 | } | |
| 1763 | ||
| 1764 | test "json.test.i_object_key_lone_2nd_surrogate" { | |
| 1765 | any( | |
| 1766 | \\{"\uDFAA":0} | |
| 1767 | ); | |
| 1768 | } | |
| 1769 | ||
| 1770 | test "json.test.i_string_1st_surrogate_but_2nd_missing" { | |
| 1771 | any( | |
| 1772 | \\["\uDADA"] | |
| 1773 | ); | |
| 1774 | } | |
| 1775 | ||
| 1776 | test "json.test.i_string_1st_valid_surrogate_2nd_invalid" { | |
| 1777 | any( | |
| 1778 | \\["\uD888\u1234"] | |
| 1779 | ); | |
| 1780 | } | |
| 1781 | ||
| 1782 | test "json.test.i_string_incomplete_surrogate_and_escape_valid" { | |
| 1783 | any( | |
| 1784 | \\["\uD800\n"] | |
| 1785 | ); | |
| 1786 | } | |
| 1787 | ||
| 1788 | test "json.test.i_string_incomplete_surrogate_pair" { | |
| 1789 | any( | |
| 1790 | \\["\uDd1ea"] | |
| 1791 | ); | |
| 1792 | } | |
| 1793 | ||
| 1794 | test "json.test.i_string_incomplete_surrogates_escape_valid" { | |
| 1795 | any( | |
| 1796 | \\["\uD800\uD800\n"] | |
| 1797 | ); | |
| 1798 | } | |
| 1799 | ||
| 1800 | test "json.test.i_string_invalid_lonely_surrogate" { | |
| 1801 | any( | |
| 1802 | \\["\ud800"] | |
| 1803 | ); | |
| 1804 | } | |
| 1805 | ||
| 1806 | test "json.test.i_string_invalid_surrogate" { | |
| 1807 | any( | |
| 1808 | \\["\ud800abc"] | |
| 1809 | ); | |
| 1810 | } | |
| 1811 | ||
| 1812 | test "json.test.i_string_invalid_utf-8" { | |
| 1813 | any( | |
| 1814 | \\["ÿ"] | |
| 1815 | ); | |
| 1816 | } | |
| 1817 | ||
| 1818 | test "json.test.i_string_inverted_surrogates_U+1D11E" { | |
| 1819 | any( | |
| 1820 | \\["\uDd1e\uD834"] | |
| 1821 | ); | |
| 1822 | } | |
| 1823 | ||
| 1824 | test "json.test.i_string_iso_latin_1" { | |
| 1825 | any( | |
| 1826 | \\["é"] | |
| 1827 | ); | |
| 1828 | } | |
| 1829 | ||
| 1830 | test "json.test.i_string_lone_second_surrogate" { | |
| 1831 | any( | |
| 1832 | \\["\uDFAA"] | |
| 1833 | ); | |
| 1834 | } | |
| 1835 | ||
| 1836 | test "json.test.i_string_lone_utf8_continuation_byte" { | |
| 1837 | any( | |
| 1838 | \\[""] | |
| 1839 | ); | |
| 1840 | } | |
| 1841 | ||
| 1842 | test "json.test.i_string_not_in_unicode_range" { | |
| 1843 | any( | |
| 1844 | \\["ô¿¿¿"] | |
| 1845 | ); | |
| 1846 | } | |
| 1847 | ||
| 1848 | test "json.test.i_string_overlong_sequence_2_bytes" { | |
| 1849 | any( | |
| 1850 | \\["À¯"] | |
| 1851 | ); | |
| 1852 | } | |
| 1853 | ||
| 1854 | test "json.test.i_string_overlong_sequence_6_bytes" { | |
| 1855 | any( | |
| 1856 | \\["ü¿¿¿¿"] | |
| 1857 | ); | |
| 1858 | } | |
| 1859 | ||
| 1860 | test "json.test.i_string_overlong_sequence_6_bytes_null" { | |
| 1861 | any( | |
| 1862 | \\["ü"] | |
| 1863 | ); | |
| 1864 | } | |
| 1865 | ||
| 1866 | test "json.test.i_string_truncated-utf-8" { | |
| 1867 | any( | |
| 1868 | \\["àÿ"] | |
| 1869 | ); | |
| 1870 | } | |
| 1871 | ||
| 1872 | test "json.test.i_string_utf16BE_no_BOM" { | |
| 1873 | any("\x00\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d"); | |
| 1874 | } | |
| 1875 | ||
| 1876 | test "json.test.i_string_utf16LE_no_BOM" { | |
| 1877 | any("\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d\x00"); | |
| 1878 | } | |
| 1879 | ||
| 1880 | test "json.test.i_string_UTF-16LE_with_BOM" { | |
| 1881 | any("\xc3\xbf\xc3\xbe\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d\x00"); | |
| 1882 | } | |
| 1883 | ||
| 1884 | test "json.test.i_string_UTF-8_invalid_sequence" { | |
| 1885 | any( | |
| 1886 | \\["æ¥Ñú"] | |
| 1887 | ); | |
| 1888 | } | |
| 1889 | ||
| 1890 | test "json.test.i_string_UTF8_surrogate_U+D800" { | |
| 1891 | any( | |
| 1892 | \\["í "] | |
| 1893 | ); | |
| 1894 | } | |
| 1895 | ||
| 1896 | test "json.test.i_structure_500_nested_arrays" { | |
| 1897 | any(("[" ** 500) ++ ("]" ** 500)); | |
| 1898 | } | |
| 1899 | ||
| 1900 | test "json.test.i_structure_UTF-8_BOM_empty_object" { | |
| 1901 | any( | |
| 1902 | \\{} | |
| 1903 | ); | |
| 1904 | } |
std/json_test.zig deleted-1904| ... | ... | @@ -1,1904 +0,0 @@ |
| 1 | // RFC 8529 conformance tests. | |
| 2 | // | |
| 3 | // Tests are taken from https://github.com/nst/JSONTestSuite | |
| 4 | // Read also http://seriot.ch/parsing_json.php for a good overview. | |
| 5 | ||
| 6 | const std = @import("std.zig"); | |
| 7 | ||
| 8 | fn ok(comptime s: []const u8) void { | |
| 9 | std.testing.expect(std.json.validate(s)); | |
| 10 | } | |
| 11 | ||
| 12 | fn err(comptime s: []const u8) void { | |
| 13 | std.testing.expect(!std.json.validate(s)); | |
| 14 | } | |
| 15 | ||
| 16 | fn any(comptime s: []const u8) void { | |
| 17 | std.testing.expect(true); | |
| 18 | } | |
| 19 | ||
| 20 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 21 | // | |
| 22 | // Additional tests not part of test JSONTestSuite. | |
| 23 | ||
| 24 | test "json.test.y_trailing_comma_after_empty" { | |
| 25 | ok( | |
| 26 | \\{"1":[],"2":{},"3":"4"} | |
| 27 | ); | |
| 28 | } | |
| 29 | ||
| 30 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 31 | ||
| 32 | test "json.test.y_array_arraysWithSpaces" { | |
| 33 | ok( | |
| 34 | \\[[] ] | |
| 35 | ); | |
| 36 | } | |
| 37 | ||
| 38 | test "json.test.y_array_empty" { | |
| 39 | ok( | |
| 40 | \\[] | |
| 41 | ); | |
| 42 | } | |
| 43 | ||
| 44 | test "json.test.y_array_empty-string" { | |
| 45 | ok( | |
| 46 | \\[""] | |
| 47 | ); | |
| 48 | } | |
| 49 | ||
| 50 | test "json.test.y_array_ending_with_newline" { | |
| 51 | ok( | |
| 52 | \\["a"] | |
| 53 | ); | |
| 54 | } | |
| 55 | ||
| 56 | test "json.test.y_array_false" { | |
| 57 | ok( | |
| 58 | \\[false] | |
| 59 | ); | |
| 60 | } | |
| 61 | ||
| 62 | test "json.test.y_array_heterogeneous" { | |
| 63 | ok( | |
| 64 | \\[null, 1, "1", {}] | |
| 65 | ); | |
| 66 | } | |
| 67 | ||
| 68 | test "json.test.y_array_null" { | |
| 69 | ok( | |
| 70 | \\[null] | |
| 71 | ); | |
| 72 | } | |
| 73 | ||
| 74 | test "json.test.y_array_with_1_and_newline" { | |
| 75 | ok( | |
| 76 | \\[1 | |
| 77 | \\] | |
| 78 | ); | |
| 79 | } | |
| 80 | ||
| 81 | test "json.test.y_array_with_leading_space" { | |
| 82 | ok( | |
| 83 | \\ [1] | |
| 84 | ); | |
| 85 | } | |
| 86 | ||
| 87 | test "json.test.y_array_with_several_null" { | |
| 88 | ok( | |
| 89 | \\[1,null,null,null,2] | |
| 90 | ); | |
| 91 | } | |
| 92 | ||
| 93 | test "json.test.y_array_with_trailing_space" { | |
| 94 | ok("[2] "); | |
| 95 | } | |
| 96 | ||
| 97 | test "json.test.y_number_0e+1" { | |
| 98 | ok( | |
| 99 | \\[0e+1] | |
| 100 | ); | |
| 101 | } | |
| 102 | ||
| 103 | test "json.test.y_number_0e1" { | |
| 104 | ok( | |
| 105 | \\[0e1] | |
| 106 | ); | |
| 107 | } | |
| 108 | ||
| 109 | test "json.test.y_number_after_space" { | |
| 110 | ok( | |
| 111 | \\[ 4] | |
| 112 | ); | |
| 113 | } | |
| 114 | ||
| 115 | test "json.test.y_number_double_close_to_zero" { | |
| 116 | ok( | |
| 117 | \\[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] | |
| 118 | ); | |
| 119 | } | |
| 120 | ||
| 121 | test "json.test.y_number_int_with_exp" { | |
| 122 | ok( | |
| 123 | \\[20e1] | |
| 124 | ); | |
| 125 | } | |
| 126 | ||
| 127 | test "json.test.y_number" { | |
| 128 | ok( | |
| 129 | \\[123e65] | |
| 130 | ); | |
| 131 | } | |
| 132 | ||
| 133 | test "json.test.y_number_minus_zero" { | |
| 134 | ok( | |
| 135 | \\[-0] | |
| 136 | ); | |
| 137 | } | |
| 138 | ||
| 139 | test "json.test.y_number_negative_int" { | |
| 140 | ok( | |
| 141 | \\[-123] | |
| 142 | ); | |
| 143 | } | |
| 144 | ||
| 145 | test "json.test.y_number_negative_one" { | |
| 146 | ok( | |
| 147 | \\[-1] | |
| 148 | ); | |
| 149 | } | |
| 150 | ||
| 151 | test "json.test.y_number_negative_zero" { | |
| 152 | ok( | |
| 153 | \\[-0] | |
| 154 | ); | |
| 155 | } | |
| 156 | ||
| 157 | test "json.test.y_number_real_capital_e" { | |
| 158 | ok( | |
| 159 | \\[1E22] | |
| 160 | ); | |
| 161 | } | |
| 162 | ||
| 163 | test "json.test.y_number_real_capital_e_neg_exp" { | |
| 164 | ok( | |
| 165 | \\[1E-2] | |
| 166 | ); | |
| 167 | } | |
| 168 | ||
| 169 | test "json.test.y_number_real_capital_e_pos_exp" { | |
| 170 | ok( | |
| 171 | \\[1E+2] | |
| 172 | ); | |
| 173 | } | |
| 174 | ||
| 175 | test "json.test.y_number_real_exponent" { | |
| 176 | ok( | |
| 177 | \\[123e45] | |
| 178 | ); | |
| 179 | } | |
| 180 | ||
| 181 | test "json.test.y_number_real_fraction_exponent" { | |
| 182 | ok( | |
| 183 | \\[123.456e78] | |
| 184 | ); | |
| 185 | } | |
| 186 | ||
| 187 | test "json.test.y_number_real_neg_exp" { | |
| 188 | ok( | |
| 189 | \\[1e-2] | |
| 190 | ); | |
| 191 | } | |
| 192 | ||
| 193 | test "json.test.y_number_real_pos_exponent" { | |
| 194 | ok( | |
| 195 | \\[1e+2] | |
| 196 | ); | |
| 197 | } | |
| 198 | ||
| 199 | test "json.test.y_number_simple_int" { | |
| 200 | ok( | |
| 201 | \\[123] | |
| 202 | ); | |
| 203 | } | |
| 204 | ||
| 205 | test "json.test.y_number_simple_real" { | |
| 206 | ok( | |
| 207 | \\[123.456789] | |
| 208 | ); | |
| 209 | } | |
| 210 | ||
| 211 | test "json.test.y_object_basic" { | |
| 212 | ok( | |
| 213 | \\{"asd":"sdf"} | |
| 214 | ); | |
| 215 | } | |
| 216 | ||
| 217 | test "json.test.y_object_duplicated_key_and_value" { | |
| 218 | ok( | |
| 219 | \\{"a":"b","a":"b"} | |
| 220 | ); | |
| 221 | } | |
| 222 | ||
| 223 | test "json.test.y_object_duplicated_key" { | |
| 224 | ok( | |
| 225 | \\{"a":"b","a":"c"} | |
| 226 | ); | |
| 227 | } | |
| 228 | ||
| 229 | test "json.test.y_object_empty" { | |
| 230 | ok( | |
| 231 | \\{} | |
| 232 | ); | |
| 233 | } | |
| 234 | ||
| 235 | test "json.test.y_object_empty_key" { | |
| 236 | ok( | |
| 237 | \\{"":0} | |
| 238 | ); | |
| 239 | } | |
| 240 | ||
| 241 | test "json.test.y_object_escaped_null_in_key" { | |
| 242 | ok( | |
| 243 | \\{"foo\u0000bar": 42} | |
| 244 | ); | |
| 245 | } | |
| 246 | ||
| 247 | test "json.test.y_object_extreme_numbers" { | |
| 248 | ok( | |
| 249 | \\{ "min": -1.0e+28, "max": 1.0e+28 } | |
| 250 | ); | |
| 251 | } | |
| 252 | ||
| 253 | test "json.test.y_object" { | |
| 254 | ok( | |
| 255 | \\{"asd":"sdf", "dfg":"fgh"} | |
| 256 | ); | |
| 257 | } | |
| 258 | ||
| 259 | test "json.test.y_object_long_strings" { | |
| 260 | ok( | |
| 261 | \\{"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} | |
| 262 | ); | |
| 263 | } | |
| 264 | ||
| 265 | test "json.test.y_object_simple" { | |
| 266 | ok( | |
| 267 | \\{"a":[]} | |
| 268 | ); | |
| 269 | } | |
| 270 | ||
| 271 | test "json.test.y_object_string_unicode" { | |
| 272 | ok( | |
| 273 | \\{"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } | |
| 274 | ); | |
| 275 | } | |
| 276 | ||
| 277 | test "json.test.y_object_with_newlines" { | |
| 278 | ok( | |
| 279 | \\{ | |
| 280 | \\"a": "b" | |
| 281 | \\} | |
| 282 | ); | |
| 283 | } | |
| 284 | ||
| 285 | test "json.test.y_string_1_2_3_bytes_UTF-8_sequences" { | |
| 286 | ok( | |
| 287 | \\["\u0060\u012a\u12AB"] | |
| 288 | ); | |
| 289 | } | |
| 290 | ||
| 291 | test "json.test.y_string_accepted_surrogate_pair" { | |
| 292 | ok( | |
| 293 | \\["\uD801\udc37"] | |
| 294 | ); | |
| 295 | } | |
| 296 | ||
| 297 | test "json.test.y_string_accepted_surrogate_pairs" { | |
| 298 | ok( | |
| 299 | \\["\ud83d\ude39\ud83d\udc8d"] | |
| 300 | ); | |
| 301 | } | |
| 302 | ||
| 303 | test "json.test.y_string_allowed_escapes" { | |
| 304 | ok( | |
| 305 | \\["\"\\\/\b\f\n\r\t"] | |
| 306 | ); | |
| 307 | } | |
| 308 | ||
| 309 | test "json.test.y_string_backslash_and_u_escaped_zero" { | |
| 310 | ok( | |
| 311 | \\["\\u0000"] | |
| 312 | ); | |
| 313 | } | |
| 314 | ||
| 315 | test "json.test.y_string_backslash_doublequotes" { | |
| 316 | ok( | |
| 317 | \\["\""] | |
| 318 | ); | |
| 319 | } | |
| 320 | ||
| 321 | test "json.test.y_string_comments" { | |
| 322 | ok( | |
| 323 | \\["a/*b*/c/*d//e"] | |
| 324 | ); | |
| 325 | } | |
| 326 | ||
| 327 | test "json.test.y_string_double_escape_a" { | |
| 328 | ok( | |
| 329 | \\["\\a"] | |
| 330 | ); | |
| 331 | } | |
| 332 | ||
| 333 | test "json.test.y_string_double_escape_n" { | |
| 334 | ok( | |
| 335 | \\["\\n"] | |
| 336 | ); | |
| 337 | } | |
| 338 | ||
| 339 | test "json.test.y_string_escaped_control_character" { | |
| 340 | ok( | |
| 341 | \\["\u0012"] | |
| 342 | ); | |
| 343 | } | |
| 344 | ||
| 345 | test "json.test.y_string_escaped_noncharacter" { | |
| 346 | ok( | |
| 347 | \\["\uFFFF"] | |
| 348 | ); | |
| 349 | } | |
| 350 | ||
| 351 | test "json.test.y_string_in_array" { | |
| 352 | ok( | |
| 353 | \\["asd"] | |
| 354 | ); | |
| 355 | } | |
| 356 | ||
| 357 | test "json.test.y_string_in_array_with_leading_space" { | |
| 358 | ok( | |
| 359 | \\[ "asd"] | |
| 360 | ); | |
| 361 | } | |
| 362 | ||
| 363 | test "json.test.y_string_last_surrogates_1_and_2" { | |
| 364 | ok( | |
| 365 | \\["\uDBFF\uDFFF"] | |
| 366 | ); | |
| 367 | } | |
| 368 | ||
| 369 | test "json.test.y_string_nbsp_uescaped" { | |
| 370 | ok( | |
| 371 | \\["new\u00A0line"] | |
| 372 | ); | |
| 373 | } | |
| 374 | ||
| 375 | test "json.test.y_string_nonCharacterInUTF-8_U+10FFFF" { | |
| 376 | ok( | |
| 377 | \\[""] | |
| 378 | ); | |
| 379 | } | |
| 380 | ||
| 381 | test "json.test.y_string_nonCharacterInUTF-8_U+FFFF" { | |
| 382 | ok( | |
| 383 | \\[""] | |
| 384 | ); | |
| 385 | } | |
| 386 | ||
| 387 | test "json.test.y_string_null_escape" { | |
| 388 | ok( | |
| 389 | \\["\u0000"] | |
| 390 | ); | |
| 391 | } | |
| 392 | ||
| 393 | test "json.test.y_string_one-byte-utf-8" { | |
| 394 | ok( | |
| 395 | \\["\u002c"] | |
| 396 | ); | |
| 397 | } | |
| 398 | ||
| 399 | test "json.test.y_string_pi" { | |
| 400 | ok( | |
| 401 | \\["π"] | |
| 402 | ); | |
| 403 | } | |
| 404 | ||
| 405 | test "json.test.y_string_reservedCharacterInUTF-8_U+1BFFF" { | |
| 406 | ok( | |
| 407 | \\[""] | |
| 408 | ); | |
| 409 | } | |
| 410 | ||
| 411 | test "json.test.y_string_simple_ascii" { | |
| 412 | ok( | |
| 413 | \\["asd "] | |
| 414 | ); | |
| 415 | } | |
| 416 | ||
| 417 | test "json.test.y_string_space" { | |
| 418 | ok( | |
| 419 | \\" " | |
| 420 | ); | |
| 421 | } | |
| 422 | ||
| 423 | test "json.test.y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF" { | |
| 424 | ok( | |
| 425 | \\["\uD834\uDd1e"] | |
| 426 | ); | |
| 427 | } | |
| 428 | ||
| 429 | test "json.test.y_string_three-byte-utf-8" { | |
| 430 | ok( | |
| 431 | \\["\u0821"] | |
| 432 | ); | |
| 433 | } | |
| 434 | ||
| 435 | test "json.test.y_string_two-byte-utf-8" { | |
| 436 | ok( | |
| 437 | \\["\u0123"] | |
| 438 | ); | |
| 439 | } | |
| 440 | ||
| 441 | test "json.test.y_string_u+2028_line_sep" { | |
| 442 | ok("[\"\xe2\x80\xa8\"]"); | |
| 443 | } | |
| 444 | ||
| 445 | test "json.test.y_string_u+2029_par_sep" { | |
| 446 | ok("[\"\xe2\x80\xa9\"]"); | |
| 447 | } | |
| 448 | ||
| 449 | test "json.test.y_string_uescaped_newline" { | |
| 450 | ok( | |
| 451 | \\["new\u000Aline"] | |
| 452 | ); | |
| 453 | } | |
| 454 | ||
| 455 | test "json.test.y_string_uEscape" { | |
| 456 | ok( | |
| 457 | \\["\u0061\u30af\u30EA\u30b9"] | |
| 458 | ); | |
| 459 | } | |
| 460 | ||
| 461 | test "json.test.y_string_unescaped_char_delete" { | |
| 462 | ok("[\"\x7f\"]"); | |
| 463 | } | |
| 464 | ||
| 465 | test "json.test.y_string_unicode_2" { | |
| 466 | ok( | |
| 467 | \\["⍂㈴⍂"] | |
| 468 | ); | |
| 469 | } | |
| 470 | ||
| 471 | test "json.test.y_string_unicodeEscapedBackslash" { | |
| 472 | ok( | |
| 473 | \\["\u005C"] | |
| 474 | ); | |
| 475 | } | |
| 476 | ||
| 477 | test "json.test.y_string_unicode_escaped_double_quote" { | |
| 478 | ok( | |
| 479 | \\["\u0022"] | |
| 480 | ); | |
| 481 | } | |
| 482 | ||
| 483 | test "json.test.y_string_unicode" { | |
| 484 | ok( | |
| 485 | \\["\uA66D"] | |
| 486 | ); | |
| 487 | } | |
| 488 | ||
| 489 | test "json.test.y_string_unicode_U+10FFFE_nonchar" { | |
| 490 | ok( | |
| 491 | \\["\uDBFF\uDFFE"] | |
| 492 | ); | |
| 493 | } | |
| 494 | ||
| 495 | test "json.test.y_string_unicode_U+1FFFE_nonchar" { | |
| 496 | ok( | |
| 497 | \\["\uD83F\uDFFE"] | |
| 498 | ); | |
| 499 | } | |
| 500 | ||
| 501 | test "json.test.y_string_unicode_U+200B_ZERO_WIDTH_SPACE" { | |
| 502 | ok( | |
| 503 | \\["\u200B"] | |
| 504 | ); | |
| 505 | } | |
| 506 | ||
| 507 | test "json.test.y_string_unicode_U+2064_invisible_plus" { | |
| 508 | ok( | |
| 509 | \\["\u2064"] | |
| 510 | ); | |
| 511 | } | |
| 512 | ||
| 513 | test "json.test.y_string_unicode_U+FDD0_nonchar" { | |
| 514 | ok( | |
| 515 | \\["\uFDD0"] | |
| 516 | ); | |
| 517 | } | |
| 518 | ||
| 519 | test "json.test.y_string_unicode_U+FFFE_nonchar" { | |
| 520 | ok( | |
| 521 | \\["\uFFFE"] | |
| 522 | ); | |
| 523 | } | |
| 524 | ||
| 525 | test "json.test.y_string_utf8" { | |
| 526 | ok( | |
| 527 | \\["€𝄞"] | |
| 528 | ); | |
| 529 | } | |
| 530 | ||
| 531 | test "json.test.y_string_with_del_character" { | |
| 532 | ok("[\"a\x7fa\"]"); | |
| 533 | } | |
| 534 | ||
| 535 | test "json.test.y_structure_lonely_false" { | |
| 536 | ok( | |
| 537 | \\false | |
| 538 | ); | |
| 539 | } | |
| 540 | ||
| 541 | test "json.test.y_structure_lonely_int" { | |
| 542 | ok( | |
| 543 | \\42 | |
| 544 | ); | |
| 545 | } | |
| 546 | ||
| 547 | test "json.test.y_structure_lonely_negative_real" { | |
| 548 | ok( | |
| 549 | \\-0.1 | |
| 550 | ); | |
| 551 | } | |
| 552 | ||
| 553 | test "json.test.y_structure_lonely_null" { | |
| 554 | ok( | |
| 555 | \\null | |
| 556 | ); | |
| 557 | } | |
| 558 | ||
| 559 | test "json.test.y_structure_lonely_string" { | |
| 560 | ok( | |
| 561 | \\"asd" | |
| 562 | ); | |
| 563 | } | |
| 564 | ||
| 565 | test "json.test.y_structure_lonely_true" { | |
| 566 | ok( | |
| 567 | \\true | |
| 568 | ); | |
| 569 | } | |
| 570 | ||
| 571 | test "json.test.y_structure_string_empty" { | |
| 572 | ok( | |
| 573 | \\"" | |
| 574 | ); | |
| 575 | } | |
| 576 | ||
| 577 | test "json.test.y_structure_trailing_newline" { | |
| 578 | ok( | |
| 579 | \\["a"] | |
| 580 | ); | |
| 581 | } | |
| 582 | ||
| 583 | test "json.test.y_structure_true_in_array" { | |
| 584 | ok( | |
| 585 | \\[true] | |
| 586 | ); | |
| 587 | } | |
| 588 | ||
| 589 | test "json.test.y_structure_whitespace_array" { | |
| 590 | ok(" [] "); | |
| 591 | } | |
| 592 | ||
| 593 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 594 | ||
| 595 | test "json.test.n_array_1_true_without_comma" { | |
| 596 | err( | |
| 597 | \\[1 true] | |
| 598 | ); | |
| 599 | } | |
| 600 | ||
| 601 | test "json.test.n_array_a_invalid_utf8" { | |
| 602 | err( | |
| 603 | \\[aå] | |
| 604 | ); | |
| 605 | } | |
| 606 | ||
| 607 | test "json.test.n_array_colon_instead_of_comma" { | |
| 608 | err( | |
| 609 | \\["": 1] | |
| 610 | ); | |
| 611 | } | |
| 612 | ||
| 613 | test "json.test.n_array_comma_after_close" { | |
| 614 | //err( | |
| 615 | // \\[""], | |
| 616 | //); | |
| 617 | } | |
| 618 | ||
| 619 | test "json.test.n_array_comma_and_number" { | |
| 620 | err( | |
| 621 | \\[,1] | |
| 622 | ); | |
| 623 | } | |
| 624 | ||
| 625 | test "json.test.n_array_double_comma" { | |
| 626 | err( | |
| 627 | \\[1,,2] | |
| 628 | ); | |
| 629 | } | |
| 630 | ||
| 631 | test "json.test.n_array_double_extra_comma" { | |
| 632 | err( | |
| 633 | \\["x",,] | |
| 634 | ); | |
| 635 | } | |
| 636 | ||
| 637 | test "json.test.n_array_extra_close" { | |
| 638 | err( | |
| 639 | \\["x"]] | |
| 640 | ); | |
| 641 | } | |
| 642 | ||
| 643 | test "json.test.n_array_extra_comma" { | |
| 644 | //err( | |
| 645 | // \\["",] | |
| 646 | //); | |
| 647 | } | |
| 648 | ||
| 649 | test "json.test.n_array_incomplete_invalid_value" { | |
| 650 | err( | |
| 651 | \\[x | |
| 652 | ); | |
| 653 | } | |
| 654 | ||
| 655 | test "json.test.n_array_incomplete" { | |
| 656 | err( | |
| 657 | \\["x" | |
| 658 | ); | |
| 659 | } | |
| 660 | ||
| 661 | test "json.test.n_array_inner_array_no_comma" { | |
| 662 | err( | |
| 663 | \\[3[4]] | |
| 664 | ); | |
| 665 | } | |
| 666 | ||
| 667 | test "json.test.n_array_invalid_utf8" { | |
| 668 | err( | |
| 669 | \\[ÿ] | |
| 670 | ); | |
| 671 | } | |
| 672 | ||
| 673 | test "json.test.n_array_items_separated_by_semicolon" { | |
| 674 | err( | |
| 675 | \\[1:2] | |
| 676 | ); | |
| 677 | } | |
| 678 | ||
| 679 | test "json.test.n_array_just_comma" { | |
| 680 | err( | |
| 681 | \\[,] | |
| 682 | ); | |
| 683 | } | |
| 684 | ||
| 685 | test "json.test.n_array_just_minus" { | |
| 686 | err( | |
| 687 | \\[-] | |
| 688 | ); | |
| 689 | } | |
| 690 | ||
| 691 | test "json.test.n_array_missing_value" { | |
| 692 | err( | |
| 693 | \\[ , ""] | |
| 694 | ); | |
| 695 | } | |
| 696 | ||
| 697 | test "json.test.n_array_newlines_unclosed" { | |
| 698 | err( | |
| 699 | \\["a", | |
| 700 | \\4 | |
| 701 | \\,1, | |
| 702 | ); | |
| 703 | } | |
| 704 | ||
| 705 | test "json.test.n_array_number_and_comma" { | |
| 706 | err( | |
| 707 | \\[1,] | |
| 708 | ); | |
| 709 | } | |
| 710 | ||
| 711 | test "json.test.n_array_number_and_several_commas" { | |
| 712 | err( | |
| 713 | \\[1,,] | |
| 714 | ); | |
| 715 | } | |
| 716 | ||
| 717 | test "json.test.n_array_spaces_vertical_tab_formfeed" { | |
| 718 | err("[\"\x0aa\"\\f]"); | |
| 719 | } | |
| 720 | ||
| 721 | test "json.test.n_array_star_inside" { | |
| 722 | err( | |
| 723 | \\[*] | |
| 724 | ); | |
| 725 | } | |
| 726 | ||
| 727 | test "json.test.n_array_unclosed" { | |
| 728 | err( | |
| 729 | \\["" | |
| 730 | ); | |
| 731 | } | |
| 732 | ||
| 733 | test "json.test.n_array_unclosed_trailing_comma" { | |
| 734 | err( | |
| 735 | \\[1, | |
| 736 | ); | |
| 737 | } | |
| 738 | ||
| 739 | test "json.test.n_array_unclosed_with_new_lines" { | |
| 740 | err( | |
| 741 | \\[1, | |
| 742 | \\1 | |
| 743 | \\,1 | |
| 744 | ); | |
| 745 | } | |
| 746 | ||
| 747 | test "json.test.n_array_unclosed_with_object_inside" { | |
| 748 | err( | |
| 749 | \\[{} | |
| 750 | ); | |
| 751 | } | |
| 752 | ||
| 753 | test "json.test.n_incomplete_false" { | |
| 754 | err( | |
| 755 | \\[fals] | |
| 756 | ); | |
| 757 | } | |
| 758 | ||
| 759 | test "json.test.n_incomplete_null" { | |
| 760 | err( | |
| 761 | \\[nul] | |
| 762 | ); | |
| 763 | } | |
| 764 | ||
| 765 | test "json.test.n_incomplete_true" { | |
| 766 | err( | |
| 767 | \\[tru] | |
| 768 | ); | |
| 769 | } | |
| 770 | ||
| 771 | test "json.test.n_multidigit_number_then_00" { | |
| 772 | err("123\x00"); | |
| 773 | } | |
| 774 | ||
| 775 | test "json.test.n_number_0.1.2" { | |
| 776 | err( | |
| 777 | \\[0.1.2] | |
| 778 | ); | |
| 779 | } | |
| 780 | ||
| 781 | test "json.test.n_number_-01" { | |
| 782 | err( | |
| 783 | \\[-01] | |
| 784 | ); | |
| 785 | } | |
| 786 | ||
| 787 | test "json.test.n_number_0.3e" { | |
| 788 | err( | |
| 789 | \\[0.3e] | |
| 790 | ); | |
| 791 | } | |
| 792 | ||
| 793 | test "json.test.n_number_0.3e+" { | |
| 794 | err( | |
| 795 | \\[0.3e+] | |
| 796 | ); | |
| 797 | } | |
| 798 | ||
| 799 | test "json.test.n_number_0_capital_E" { | |
| 800 | err( | |
| 801 | \\[0E] | |
| 802 | ); | |
| 803 | } | |
| 804 | ||
| 805 | test "json.test.n_number_0_capital_E+" { | |
| 806 | err( | |
| 807 | \\[0E+] | |
| 808 | ); | |
| 809 | } | |
| 810 | ||
| 811 | test "json.test.n_number_0.e1" { | |
| 812 | err( | |
| 813 | \\[0.e1] | |
| 814 | ); | |
| 815 | } | |
| 816 | ||
| 817 | test "json.test.n_number_0e" { | |
| 818 | err( | |
| 819 | \\[0e] | |
| 820 | ); | |
| 821 | } | |
| 822 | ||
| 823 | test "json.test.n_number_0e+" { | |
| 824 | err( | |
| 825 | \\[0e+] | |
| 826 | ); | |
| 827 | } | |
| 828 | ||
| 829 | test "json.test.n_number_1_000" { | |
| 830 | err( | |
| 831 | \\[1 000.0] | |
| 832 | ); | |
| 833 | } | |
| 834 | ||
| 835 | test "json.test.n_number_1.0e-" { | |
| 836 | err( | |
| 837 | \\[1.0e-] | |
| 838 | ); | |
| 839 | } | |
| 840 | ||
| 841 | test "json.test.n_number_1.0e" { | |
| 842 | err( | |
| 843 | \\[1.0e] | |
| 844 | ); | |
| 845 | } | |
| 846 | ||
| 847 | test "json.test.n_number_1.0e+" { | |
| 848 | err( | |
| 849 | \\[1.0e+] | |
| 850 | ); | |
| 851 | } | |
| 852 | ||
| 853 | test "json.test.n_number_-1.0." { | |
| 854 | err( | |
| 855 | \\[-1.0.] | |
| 856 | ); | |
| 857 | } | |
| 858 | ||
| 859 | test "json.test.n_number_1eE2" { | |
| 860 | err( | |
| 861 | \\[1eE2] | |
| 862 | ); | |
| 863 | } | |
| 864 | ||
| 865 | test "json.test.n_number_.-1" { | |
| 866 | err( | |
| 867 | \\[.-1] | |
| 868 | ); | |
| 869 | } | |
| 870 | ||
| 871 | test "json.test.n_number_+1" { | |
| 872 | err( | |
| 873 | \\[+1] | |
| 874 | ); | |
| 875 | } | |
| 876 | ||
| 877 | test "json.test.n_number_.2e-3" { | |
| 878 | err( | |
| 879 | \\[.2e-3] | |
| 880 | ); | |
| 881 | } | |
| 882 | ||
| 883 | test "json.test.n_number_2.e-3" { | |
| 884 | err( | |
| 885 | \\[2.e-3] | |
| 886 | ); | |
| 887 | } | |
| 888 | ||
| 889 | test "json.test.n_number_2.e+3" { | |
| 890 | err( | |
| 891 | \\[2.e+3] | |
| 892 | ); | |
| 893 | } | |
| 894 | ||
| 895 | test "json.test.n_number_2.e3" { | |
| 896 | err( | |
| 897 | \\[2.e3] | |
| 898 | ); | |
| 899 | } | |
| 900 | ||
| 901 | test "json.test.n_number_-2." { | |
| 902 | err( | |
| 903 | \\[-2.] | |
| 904 | ); | |
| 905 | } | |
| 906 | ||
| 907 | test "json.test.n_number_9.e+" { | |
| 908 | err( | |
| 909 | \\[9.e+] | |
| 910 | ); | |
| 911 | } | |
| 912 | ||
| 913 | test "json.test.n_number_expression" { | |
| 914 | err( | |
| 915 | \\[1+2] | |
| 916 | ); | |
| 917 | } | |
| 918 | ||
| 919 | test "json.test.n_number_hex_1_digit" { | |
| 920 | err( | |
| 921 | \\[0x1] | |
| 922 | ); | |
| 923 | } | |
| 924 | ||
| 925 | test "json.test.n_number_hex_2_digits" { | |
| 926 | err( | |
| 927 | \\[0x42] | |
| 928 | ); | |
| 929 | } | |
| 930 | ||
| 931 | test "json.test.n_number_infinity" { | |
| 932 | err( | |
| 933 | \\[Infinity] | |
| 934 | ); | |
| 935 | } | |
| 936 | ||
| 937 | test "json.test.n_number_+Inf" { | |
| 938 | err( | |
| 939 | \\[+Inf] | |
| 940 | ); | |
| 941 | } | |
| 942 | ||
| 943 | test "json.test.n_number_Inf" { | |
| 944 | err( | |
| 945 | \\[Inf] | |
| 946 | ); | |
| 947 | } | |
| 948 | ||
| 949 | test "json.test.n_number_invalid+-" { | |
| 950 | err( | |
| 951 | \\[0e+-1] | |
| 952 | ); | |
| 953 | } | |
| 954 | ||
| 955 | test "json.test.n_number_invalid-negative-real" { | |
| 956 | err( | |
| 957 | \\[-123.123foo] | |
| 958 | ); | |
| 959 | } | |
| 960 | ||
| 961 | test "json.test.n_number_invalid-utf-8-in-bigger-int" { | |
| 962 | err( | |
| 963 | \\[123å] | |
| 964 | ); | |
| 965 | } | |
| 966 | ||
| 967 | test "json.test.n_number_invalid-utf-8-in-exponent" { | |
| 968 | err( | |
| 969 | \\[1e1å] | |
| 970 | ); | |
| 971 | } | |
| 972 | ||
| 973 | test "json.test.n_number_invalid-utf-8-in-int" { | |
| 974 | err( | |
| 975 | \\[0å] | |
| 976 | ); | |
| 977 | } | |
| 978 | ||
| 979 | test "json.test.n_number_++" { | |
| 980 | err( | |
| 981 | \\[++1234] | |
| 982 | ); | |
| 983 | } | |
| 984 | ||
| 985 | test "json.test.n_number_minus_infinity" { | |
| 986 | err( | |
| 987 | \\[-Infinity] | |
| 988 | ); | |
| 989 | } | |
| 990 | ||
| 991 | test "json.test.n_number_minus_sign_with_trailing_garbage" { | |
| 992 | err( | |
| 993 | \\[-foo] | |
| 994 | ); | |
| 995 | } | |
| 996 | ||
| 997 | test "json.test.n_number_minus_space_1" { | |
| 998 | err( | |
| 999 | \\[- 1] | |
| 1000 | ); | |
| 1001 | } | |
| 1002 | ||
| 1003 | test "json.test.n_number_-NaN" { | |
| 1004 | err( | |
| 1005 | \\[-NaN] | |
| 1006 | ); | |
| 1007 | } | |
| 1008 | ||
| 1009 | test "json.test.n_number_NaN" { | |
| 1010 | err( | |
| 1011 | \\[NaN] | |
| 1012 | ); | |
| 1013 | } | |
| 1014 | ||
| 1015 | test "json.test.n_number_neg_int_starting_with_zero" { | |
| 1016 | err( | |
| 1017 | \\[-012] | |
| 1018 | ); | |
| 1019 | } | |
| 1020 | ||
| 1021 | test "json.test.n_number_neg_real_without_int_part" { | |
| 1022 | err( | |
| 1023 | \\[-.123] | |
| 1024 | ); | |
| 1025 | } | |
| 1026 | ||
| 1027 | test "json.test.n_number_neg_with_garbage_at_end" { | |
| 1028 | err( | |
| 1029 | \\[-1x] | |
| 1030 | ); | |
| 1031 | } | |
| 1032 | ||
| 1033 | test "json.test.n_number_real_garbage_after_e" { | |
| 1034 | err( | |
| 1035 | \\[1ea] | |
| 1036 | ); | |
| 1037 | } | |
| 1038 | ||
| 1039 | test "json.test.n_number_real_with_invalid_utf8_after_e" { | |
| 1040 | err( | |
| 1041 | \\[1eå] | |
| 1042 | ); | |
| 1043 | } | |
| 1044 | ||
| 1045 | test "json.test.n_number_real_without_fractional_part" { | |
| 1046 | err( | |
| 1047 | \\[1.] | |
| 1048 | ); | |
| 1049 | } | |
| 1050 | ||
| 1051 | test "json.test.n_number_starting_with_dot" { | |
| 1052 | err( | |
| 1053 | \\[.123] | |
| 1054 | ); | |
| 1055 | } | |
| 1056 | ||
| 1057 | test "json.test.n_number_U+FF11_fullwidth_digit_one" { | |
| 1058 | err( | |
| 1059 | \\[ï¼] | |
| 1060 | ); | |
| 1061 | } | |
| 1062 | ||
| 1063 | test "json.test.n_number_with_alpha_char" { | |
| 1064 | err( | |
| 1065 | \\[1.8011670033376514H-308] | |
| 1066 | ); | |
| 1067 | } | |
| 1068 | ||
| 1069 | test "json.test.n_number_with_alpha" { | |
| 1070 | err( | |
| 1071 | \\[1.2a-3] | |
| 1072 | ); | |
| 1073 | } | |
| 1074 | ||
| 1075 | test "json.test.n_number_with_leading_zero" { | |
| 1076 | err( | |
| 1077 | \\[012] | |
| 1078 | ); | |
| 1079 | } | |
| 1080 | ||
| 1081 | test "json.test.n_object_bad_value" { | |
| 1082 | err( | |
| 1083 | \\["x", truth] | |
| 1084 | ); | |
| 1085 | } | |
| 1086 | ||
| 1087 | test "json.test.n_object_bracket_key" { | |
| 1088 | err( | |
| 1089 | \\{[: "x"} | |
| 1090 | ); | |
| 1091 | } | |
| 1092 | ||
| 1093 | test "json.test.n_object_comma_instead_of_colon" { | |
| 1094 | err( | |
| 1095 | \\{"x", null} | |
| 1096 | ); | |
| 1097 | } | |
| 1098 | ||
| 1099 | test "json.test.n_object_double_colon" { | |
| 1100 | err( | |
| 1101 | \\{"x"::"b"} | |
| 1102 | ); | |
| 1103 | } | |
| 1104 | ||
| 1105 | test "json.test.n_object_emoji" { | |
| 1106 | err( | |
| 1107 | \\{ð¨ð} | |
| 1108 | ); | |
| 1109 | } | |
| 1110 | ||
| 1111 | test "json.test.n_object_garbage_at_end" { | |
| 1112 | err( | |
| 1113 | \\{"a":"a" 123} | |
| 1114 | ); | |
| 1115 | } | |
| 1116 | ||
| 1117 | test "json.test.n_object_key_with_single_quotes" { | |
| 1118 | err( | |
| 1119 | \\{key: 'value'} | |
| 1120 | ); | |
| 1121 | } | |
| 1122 | ||
| 1123 | test "json.test.n_object_lone_continuation_byte_in_key_and_trailing_comma" { | |
| 1124 | err( | |
| 1125 | \\{"¹":"0",} | |
| 1126 | ); | |
| 1127 | } | |
| 1128 | ||
| 1129 | test "json.test.n_object_missing_colon" { | |
| 1130 | err( | |
| 1131 | \\{"a" b} | |
| 1132 | ); | |
| 1133 | } | |
| 1134 | ||
| 1135 | test "json.test.n_object_missing_key" { | |
| 1136 | err( | |
| 1137 | \\{:"b"} | |
| 1138 | ); | |
| 1139 | } | |
| 1140 | ||
| 1141 | test "json.test.n_object_missing_semicolon" { | |
| 1142 | err( | |
| 1143 | \\{"a" "b"} | |
| 1144 | ); | |
| 1145 | } | |
| 1146 | ||
| 1147 | test "json.test.n_object_missing_value" { | |
| 1148 | err( | |
| 1149 | \\{"a": | |
| 1150 | ); | |
| 1151 | } | |
| 1152 | ||
| 1153 | test "json.test.n_object_no-colon" { | |
| 1154 | err( | |
| 1155 | \\{"a" | |
| 1156 | ); | |
| 1157 | } | |
| 1158 | ||
| 1159 | test "json.test.n_object_non_string_key_but_huge_number_instead" { | |
| 1160 | err( | |
| 1161 | \\{9999E9999:1} | |
| 1162 | ); | |
| 1163 | } | |
| 1164 | ||
| 1165 | test "json.test.n_object_non_string_key" { | |
| 1166 | err( | |
| 1167 | \\{1:1} | |
| 1168 | ); | |
| 1169 | } | |
| 1170 | ||
| 1171 | test "json.test.n_object_repeated_null_null" { | |
| 1172 | err( | |
| 1173 | \\{null:null,null:null} | |
| 1174 | ); | |
| 1175 | } | |
| 1176 | ||
| 1177 | test "json.test.n_object_several_trailing_commas" { | |
| 1178 | err( | |
| 1179 | \\{"id":0,,,,,} | |
| 1180 | ); | |
| 1181 | } | |
| 1182 | ||
| 1183 | test "json.test.n_object_single_quote" { | |
| 1184 | err( | |
| 1185 | \\{'a':0} | |
| 1186 | ); | |
| 1187 | } | |
| 1188 | ||
| 1189 | test "json.test.n_object_trailing_comma" { | |
| 1190 | err( | |
| 1191 | \\{"id":0,} | |
| 1192 | ); | |
| 1193 | } | |
| 1194 | ||
| 1195 | test "json.test.n_object_trailing_comment" { | |
| 1196 | err( | |
| 1197 | \\{"a":"b"}/**/ | |
| 1198 | ); | |
| 1199 | } | |
| 1200 | ||
| 1201 | test "json.test.n_object_trailing_comment_open" { | |
| 1202 | err( | |
| 1203 | \\{"a":"b"}/**// | |
| 1204 | ); | |
| 1205 | } | |
| 1206 | ||
| 1207 | test "json.test.n_object_trailing_comment_slash_open_incomplete" { | |
| 1208 | err( | |
| 1209 | \\{"a":"b"}/ | |
| 1210 | ); | |
| 1211 | } | |
| 1212 | ||
| 1213 | test "json.test.n_object_trailing_comment_slash_open" { | |
| 1214 | err( | |
| 1215 | \\{"a":"b"}// | |
| 1216 | ); | |
| 1217 | } | |
| 1218 | ||
| 1219 | test "json.test.n_object_two_commas_in_a_row" { | |
| 1220 | err( | |
| 1221 | \\{"a":"b",,"c":"d"} | |
| 1222 | ); | |
| 1223 | } | |
| 1224 | ||
| 1225 | test "json.test.n_object_unquoted_key" { | |
| 1226 | err( | |
| 1227 | \\{a: "b"} | |
| 1228 | ); | |
| 1229 | } | |
| 1230 | ||
| 1231 | test "json.test.n_object_unterminated-value" { | |
| 1232 | err( | |
| 1233 | \\{"a":"a | |
| 1234 | ); | |
| 1235 | } | |
| 1236 | ||
| 1237 | test "json.test.n_object_with_single_string" { | |
| 1238 | err( | |
| 1239 | \\{ "foo" : "bar", "a" } | |
| 1240 | ); | |
| 1241 | } | |
| 1242 | ||
| 1243 | test "json.test.n_object_with_trailing_garbage" { | |
| 1244 | err( | |
| 1245 | \\{"a":"b"}# | |
| 1246 | ); | |
| 1247 | } | |
| 1248 | ||
| 1249 | test "json.test.n_single_space" { | |
| 1250 | err(" "); | |
| 1251 | } | |
| 1252 | ||
| 1253 | test "json.test.n_string_1_surrogate_then_escape" { | |
| 1254 | err( | |
| 1255 | \\["\uD800\"] | |
| 1256 | ); | |
| 1257 | } | |
| 1258 | ||
| 1259 | test "json.test.n_string_1_surrogate_then_escape_u1" { | |
| 1260 | err( | |
| 1261 | \\["\uD800\u1"] | |
| 1262 | ); | |
| 1263 | } | |
| 1264 | ||
| 1265 | test "json.test.n_string_1_surrogate_then_escape_u1x" { | |
| 1266 | err( | |
| 1267 | \\["\uD800\u1x"] | |
| 1268 | ); | |
| 1269 | } | |
| 1270 | ||
| 1271 | test "json.test.n_string_1_surrogate_then_escape_u" { | |
| 1272 | err( | |
| 1273 | \\["\uD800\u"] | |
| 1274 | ); | |
| 1275 | } | |
| 1276 | ||
| 1277 | test "json.test.n_string_accentuated_char_no_quotes" { | |
| 1278 | err( | |
| 1279 | \\[é] | |
| 1280 | ); | |
| 1281 | } | |
| 1282 | ||
| 1283 | test "json.test.n_string_backslash_00" { | |
| 1284 | err("[\"\x00\"]"); | |
| 1285 | } | |
| 1286 | ||
| 1287 | test "json.test.n_string_escaped_backslash_bad" { | |
| 1288 | err( | |
| 1289 | \\["\\\"] | |
| 1290 | ); | |
| 1291 | } | |
| 1292 | ||
| 1293 | test "json.test.n_string_escaped_ctrl_char_tab" { | |
| 1294 | err("\x5b\x22\x5c\x09\x22\x5d"); | |
| 1295 | } | |
| 1296 | ||
| 1297 | test "json.test.n_string_escaped_emoji" { | |
| 1298 | err("[\"\x5c\xc3\xb0\xc2\x9f\xc2\x8c\xc2\x80\"]"); | |
| 1299 | } | |
| 1300 | ||
| 1301 | test "json.test.n_string_escape_x" { | |
| 1302 | err( | |
| 1303 | \\["\x00"] | |
| 1304 | ); | |
| 1305 | } | |
| 1306 | ||
| 1307 | test "json.test.n_string_incomplete_escaped_character" { | |
| 1308 | err( | |
| 1309 | \\["\u00A"] | |
| 1310 | ); | |
| 1311 | } | |
| 1312 | ||
| 1313 | test "json.test.n_string_incomplete_escape" { | |
| 1314 | err( | |
| 1315 | \\["\"] | |
| 1316 | ); | |
| 1317 | } | |
| 1318 | ||
| 1319 | test "json.test.n_string_incomplete_surrogate_escape_invalid" { | |
| 1320 | err( | |
| 1321 | \\["\uD800\uD800\x"] | |
| 1322 | ); | |
| 1323 | } | |
| 1324 | ||
| 1325 | test "json.test.n_string_incomplete_surrogate" { | |
| 1326 | err( | |
| 1327 | \\["\uD834\uDd"] | |
| 1328 | ); | |
| 1329 | } | |
| 1330 | ||
| 1331 | test "json.test.n_string_invalid_backslash_esc" { | |
| 1332 | err( | |
| 1333 | \\["\a"] | |
| 1334 | ); | |
| 1335 | } | |
| 1336 | ||
| 1337 | test "json.test.n_string_invalid_unicode_escape" { | |
| 1338 | err( | |
| 1339 | \\["\uqqqq"] | |
| 1340 | ); | |
| 1341 | } | |
| 1342 | ||
| 1343 | test "json.test.n_string_invalid_utf8_after_escape" { | |
| 1344 | err("[\"\\\x75\xc3\xa5\"]"); | |
| 1345 | } | |
| 1346 | ||
| 1347 | test "json.test.n_string_invalid-utf-8-in-escape" { | |
| 1348 | err( | |
| 1349 | \\["\uå"] | |
| 1350 | ); | |
| 1351 | } | |
| 1352 | ||
| 1353 | test "json.test.n_string_leading_uescaped_thinspace" { | |
| 1354 | err( | |
| 1355 | \\[\u0020"asd"] | |
| 1356 | ); | |
| 1357 | } | |
| 1358 | ||
| 1359 | test "json.test.n_string_no_quotes_with_bad_escape" { | |
| 1360 | err( | |
| 1361 | \\[\n] | |
| 1362 | ); | |
| 1363 | } | |
| 1364 | ||
| 1365 | test "json.test.n_string_single_doublequote" { | |
| 1366 | err( | |
| 1367 | \\" | |
| 1368 | ); | |
| 1369 | } | |
| 1370 | ||
| 1371 | test "json.test.n_string_single_quote" { | |
| 1372 | err( | |
| 1373 | \\['single quote'] | |
| 1374 | ); | |
| 1375 | } | |
| 1376 | ||
| 1377 | test "json.test.n_string_single_string_no_double_quotes" { | |
| 1378 | err( | |
| 1379 | \\abc | |
| 1380 | ); | |
| 1381 | } | |
| 1382 | ||
| 1383 | test "json.test.n_string_start_escape_unclosed" { | |
| 1384 | err( | |
| 1385 | \\["\ | |
| 1386 | ); | |
| 1387 | } | |
| 1388 | ||
| 1389 | test "json.test.n_string_unescaped_crtl_char" { | |
| 1390 | err("[\"a\x00a\"]"); | |
| 1391 | } | |
| 1392 | ||
| 1393 | test "json.test.n_string_unescaped_newline" { | |
| 1394 | err( | |
| 1395 | \\["new | |
| 1396 | \\line"] | |
| 1397 | ); | |
| 1398 | } | |
| 1399 | ||
| 1400 | test "json.test.n_string_unescaped_tab" { | |
| 1401 | err("[\"\t\"]"); | |
| 1402 | } | |
| 1403 | ||
| 1404 | test "json.test.n_string_unicode_CapitalU" { | |
| 1405 | err( | |
| 1406 | \\"\UA66D" | |
| 1407 | ); | |
| 1408 | } | |
| 1409 | ||
| 1410 | test "json.test.n_string_with_trailing_garbage" { | |
| 1411 | err( | |
| 1412 | \\""x | |
| 1413 | ); | |
| 1414 | } | |
| 1415 | ||
| 1416 | test "json.test.n_structure_100000_opening_arrays" { | |
| 1417 | err("[" ** 100000); | |
| 1418 | } | |
| 1419 | ||
| 1420 | test "json.test.n_structure_angle_bracket_." { | |
| 1421 | err( | |
| 1422 | \\<.> | |
| 1423 | ); | |
| 1424 | } | |
| 1425 | ||
| 1426 | test "json.test.n_structure_angle_bracket_null" { | |
| 1427 | err( | |
| 1428 | \\[<null>] | |
| 1429 | ); | |
| 1430 | } | |
| 1431 | ||
| 1432 | test "json.test.n_structure_array_trailing_garbage" { | |
| 1433 | err( | |
| 1434 | \\[1]x | |
| 1435 | ); | |
| 1436 | } | |
| 1437 | ||
| 1438 | test "json.test.n_structure_array_with_extra_array_close" { | |
| 1439 | err( | |
| 1440 | \\[1]] | |
| 1441 | ); | |
| 1442 | } | |
| 1443 | ||
| 1444 | test "json.test.n_structure_array_with_unclosed_string" { | |
| 1445 | err( | |
| 1446 | \\["asd] | |
| 1447 | ); | |
| 1448 | } | |
| 1449 | ||
| 1450 | test "json.test.n_structure_ascii-unicode-identifier" { | |
| 1451 | err( | |
| 1452 | \\aå | |
| 1453 | ); | |
| 1454 | } | |
| 1455 | ||
| 1456 | test "json.test.n_structure_capitalized_True" { | |
| 1457 | err( | |
| 1458 | \\[True] | |
| 1459 | ); | |
| 1460 | } | |
| 1461 | ||
| 1462 | test "json.test.n_structure_close_unopened_array" { | |
| 1463 | err( | |
| 1464 | \\1] | |
| 1465 | ); | |
| 1466 | } | |
| 1467 | ||
| 1468 | test "json.test.n_structure_comma_instead_of_closing_brace" { | |
| 1469 | err( | |
| 1470 | \\{"x": true, | |
| 1471 | ); | |
| 1472 | } | |
| 1473 | ||
| 1474 | test "json.test.n_structure_double_array" { | |
| 1475 | err( | |
| 1476 | \\[][] | |
| 1477 | ); | |
| 1478 | } | |
| 1479 | ||
| 1480 | test "json.test.n_structure_end_array" { | |
| 1481 | err( | |
| 1482 | \\] | |
| 1483 | ); | |
| 1484 | } | |
| 1485 | ||
| 1486 | test "json.test.n_structure_incomplete_UTF8_BOM" { | |
| 1487 | err( | |
| 1488 | \\ï»{} | |
| 1489 | ); | |
| 1490 | } | |
| 1491 | ||
| 1492 | test "json.test.n_structure_lone-invalid-utf-8" { | |
| 1493 | err( | |
| 1494 | \\å | |
| 1495 | ); | |
| 1496 | } | |
| 1497 | ||
| 1498 | test "json.test.n_structure_lone-open-bracket" { | |
| 1499 | err( | |
| 1500 | \\[ | |
| 1501 | ); | |
| 1502 | } | |
| 1503 | ||
| 1504 | test "json.test.n_structure_no_data" { | |
| 1505 | err( | |
| 1506 | \\ | |
| 1507 | ); | |
| 1508 | } | |
| 1509 | ||
| 1510 | test "json.test.n_structure_null-byte-outside-string" { | |
| 1511 | err("[\x00]"); | |
| 1512 | } | |
| 1513 | ||
| 1514 | test "json.test.n_structure_number_with_trailing_garbage" { | |
| 1515 | err( | |
| 1516 | \\2@ | |
| 1517 | ); | |
| 1518 | } | |
| 1519 | ||
| 1520 | test "json.test.n_structure_object_followed_by_closing_object" { | |
| 1521 | err( | |
| 1522 | \\{}} | |
| 1523 | ); | |
| 1524 | } | |
| 1525 | ||
| 1526 | test "json.test.n_structure_object_unclosed_no_value" { | |
| 1527 | err( | |
| 1528 | \\{"": | |
| 1529 | ); | |
| 1530 | } | |
| 1531 | ||
| 1532 | test "json.test.n_structure_object_with_comment" { | |
| 1533 | err( | |
| 1534 | \\{"a":/*comment*/"b"} | |
| 1535 | ); | |
| 1536 | } | |
| 1537 | ||
| 1538 | test "json.test.n_structure_object_with_trailing_garbage" { | |
| 1539 | err( | |
| 1540 | \\{"a": true} "x" | |
| 1541 | ); | |
| 1542 | } | |
| 1543 | ||
| 1544 | test "json.test.n_structure_open_array_apostrophe" { | |
| 1545 | err( | |
| 1546 | \\[' | |
| 1547 | ); | |
| 1548 | } | |
| 1549 | ||
| 1550 | test "json.test.n_structure_open_array_comma" { | |
| 1551 | err( | |
| 1552 | \\[, | |
| 1553 | ); | |
| 1554 | } | |
| 1555 | ||
| 1556 | test "json.test.n_structure_open_array_object" { | |
| 1557 | err("[{\"\":" ** 50000); | |
| 1558 | } | |
| 1559 | ||
| 1560 | test "json.test.n_structure_open_array_open_object" { | |
| 1561 | err( | |
| 1562 | \\[{ | |
| 1563 | ); | |
| 1564 | } | |
| 1565 | ||
| 1566 | test "json.test.n_structure_open_array_open_string" { | |
| 1567 | err( | |
| 1568 | \\["a | |
| 1569 | ); | |
| 1570 | } | |
| 1571 | ||
| 1572 | test "json.test.n_structure_open_array_string" { | |
| 1573 | err( | |
| 1574 | \\["a" | |
| 1575 | ); | |
| 1576 | } | |
| 1577 | ||
| 1578 | test "json.test.n_structure_open_object_close_array" { | |
| 1579 | err( | |
| 1580 | \\{] | |
| 1581 | ); | |
| 1582 | } | |
| 1583 | ||
| 1584 | test "json.test.n_structure_open_object_comma" { | |
| 1585 | err( | |
| 1586 | \\{, | |
| 1587 | ); | |
| 1588 | } | |
| 1589 | ||
| 1590 | test "json.test.n_structure_open_object" { | |
| 1591 | err( | |
| 1592 | \\{ | |
| 1593 | ); | |
| 1594 | } | |
| 1595 | ||
| 1596 | test "json.test.n_structure_open_object_open_array" { | |
| 1597 | err( | |
| 1598 | \\{[ | |
| 1599 | ); | |
| 1600 | } | |
| 1601 | ||
| 1602 | test "json.test.n_structure_open_object_open_string" { | |
| 1603 | err( | |
| 1604 | \\{"a | |
| 1605 | ); | |
| 1606 | } | |
| 1607 | ||
| 1608 | test "json.test.n_structure_open_object_string_with_apostrophes" { | |
| 1609 | err( | |
| 1610 | \\{'a' | |
| 1611 | ); | |
| 1612 | } | |
| 1613 | ||
| 1614 | test "json.test.n_structure_open_open" { | |
| 1615 | err( | |
| 1616 | \\["\{["\{["\{["\{ | |
| 1617 | ); | |
| 1618 | } | |
| 1619 | ||
| 1620 | test "json.test.n_structure_single_eacute" { | |
| 1621 | err( | |
| 1622 | \\é | |
| 1623 | ); | |
| 1624 | } | |
| 1625 | ||
| 1626 | test "json.test.n_structure_single_star" { | |
| 1627 | err( | |
| 1628 | \\* | |
| 1629 | ); | |
| 1630 | } | |
| 1631 | ||
| 1632 | test "json.test.n_structure_trailing_#" { | |
| 1633 | err( | |
| 1634 | \\{"a":"b"}#{} | |
| 1635 | ); | |
| 1636 | } | |
| 1637 | ||
| 1638 | test "json.test.n_structure_U+2060_word_joined" { | |
| 1639 | err( | |
| 1640 | \\[â ] | |
| 1641 | ); | |
| 1642 | } | |
| 1643 | ||
| 1644 | test "json.test.n_structure_uescaped_LF_before_string" { | |
| 1645 | err( | |
| 1646 | \\[\u000A""] | |
| 1647 | ); | |
| 1648 | } | |
| 1649 | ||
| 1650 | test "json.test.n_structure_unclosed_array" { | |
| 1651 | err( | |
| 1652 | \\[1 | |
| 1653 | ); | |
| 1654 | } | |
| 1655 | ||
| 1656 | test "json.test.n_structure_unclosed_array_partial_null" { | |
| 1657 | err( | |
| 1658 | \\[ false, nul | |
| 1659 | ); | |
| 1660 | } | |
| 1661 | ||
| 1662 | test "json.test.n_structure_unclosed_array_unfinished_false" { | |
| 1663 | err( | |
| 1664 | \\[ true, fals | |
| 1665 | ); | |
| 1666 | } | |
| 1667 | ||
| 1668 | test "json.test.n_structure_unclosed_array_unfinished_true" { | |
| 1669 | err( | |
| 1670 | \\[ false, tru | |
| 1671 | ); | |
| 1672 | } | |
| 1673 | ||
| 1674 | test "json.test.n_structure_unclosed_object" { | |
| 1675 | err( | |
| 1676 | \\{"asd":"asd" | |
| 1677 | ); | |
| 1678 | } | |
| 1679 | ||
| 1680 | test "json.test.n_structure_unicode-identifier" { | |
| 1681 | err( | |
| 1682 | \\Ã¥ | |
| 1683 | ); | |
| 1684 | } | |
| 1685 | ||
| 1686 | test "json.test.n_structure_UTF8_BOM_no_data" { | |
| 1687 | err( | |
| 1688 | \\ | |
| 1689 | ); | |
| 1690 | } | |
| 1691 | ||
| 1692 | test "json.test.n_structure_whitespace_formfeed" { | |
| 1693 | err("[\x0c]"); | |
| 1694 | } | |
| 1695 | ||
| 1696 | test "json.test.n_structure_whitespace_U+2060_word_joiner" { | |
| 1697 | err( | |
| 1698 | \\[â ] | |
| 1699 | ); | |
| 1700 | } | |
| 1701 | ||
| 1702 | //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 1703 | ||
| 1704 | test "json.test.i_number_double_huge_neg_exp" { | |
| 1705 | any( | |
| 1706 | \\[123.456e-789] | |
| 1707 | ); | |
| 1708 | } | |
| 1709 | ||
| 1710 | test "json.test.i_number_huge_exp" { | |
| 1711 | any( | |
| 1712 | \\[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006] | |
| 1713 | ); | |
| 1714 | } | |
| 1715 | ||
| 1716 | test "json.test.i_number_neg_int_huge_exp" { | |
| 1717 | any( | |
| 1718 | \\[-1e+9999] | |
| 1719 | ); | |
| 1720 | } | |
| 1721 | ||
| 1722 | test "json.test.i_number_pos_double_huge_exp" { | |
| 1723 | any( | |
| 1724 | \\[1.5e+9999] | |
| 1725 | ); | |
| 1726 | } | |
| 1727 | ||
| 1728 | test "json.test.i_number_real_neg_overflow" { | |
| 1729 | any( | |
| 1730 | \\[-123123e100000] | |
| 1731 | ); | |
| 1732 | } | |
| 1733 | ||
| 1734 | test "json.test.i_number_real_pos_overflow" { | |
| 1735 | any( | |
| 1736 | \\[123123e100000] | |
| 1737 | ); | |
| 1738 | } | |
| 1739 | ||
| 1740 | test "json.test.i_number_real_underflow" { | |
| 1741 | any( | |
| 1742 | \\[123e-10000000] | |
| 1743 | ); | |
| 1744 | } | |
| 1745 | ||
| 1746 | test "json.test.i_number_too_big_neg_int" { | |
| 1747 | any( | |
| 1748 | \\[-123123123123123123123123123123] | |
| 1749 | ); | |
| 1750 | } | |
| 1751 | ||
| 1752 | test "json.test.i_number_too_big_pos_int" { | |
| 1753 | any( | |
| 1754 | \\[100000000000000000000] | |
| 1755 | ); | |
| 1756 | } | |
| 1757 | ||
| 1758 | test "json.test.i_number_very_big_negative_int" { | |
| 1759 | any( | |
| 1760 | \\[-237462374673276894279832749832423479823246327846] | |
| 1761 | ); | |
| 1762 | } | |
| 1763 | ||
| 1764 | test "json.test.i_object_key_lone_2nd_surrogate" { | |
| 1765 | any( | |
| 1766 | \\{"\uDFAA":0} | |
| 1767 | ); | |
| 1768 | } | |
| 1769 | ||
| 1770 | test "json.test.i_string_1st_surrogate_but_2nd_missing" { | |
| 1771 | any( | |
| 1772 | \\["\uDADA"] | |
| 1773 | ); | |
| 1774 | } | |
| 1775 | ||
| 1776 | test "json.test.i_string_1st_valid_surrogate_2nd_invalid" { | |
| 1777 | any( | |
| 1778 | \\["\uD888\u1234"] | |
| 1779 | ); | |
| 1780 | } | |
| 1781 | ||
| 1782 | test "json.test.i_string_incomplete_surrogate_and_escape_valid" { | |
| 1783 | any( | |
| 1784 | \\["\uD800\n"] | |
| 1785 | ); | |
| 1786 | } | |
| 1787 | ||
| 1788 | test "json.test.i_string_incomplete_surrogate_pair" { | |
| 1789 | any( | |
| 1790 | \\["\uDd1ea"] | |
| 1791 | ); | |
| 1792 | } | |
| 1793 | ||
| 1794 | test "json.test.i_string_incomplete_surrogates_escape_valid" { | |
| 1795 | any( | |
| 1796 | \\["\uD800\uD800\n"] | |
| 1797 | ); | |
| 1798 | } | |
| 1799 | ||
| 1800 | test "json.test.i_string_invalid_lonely_surrogate" { | |
| 1801 | any( | |
| 1802 | \\["\ud800"] | |
| 1803 | ); | |
| 1804 | } | |
| 1805 | ||
| 1806 | test "json.test.i_string_invalid_surrogate" { | |
| 1807 | any( | |
| 1808 | \\["\ud800abc"] | |
| 1809 | ); | |
| 1810 | } | |
| 1811 | ||
| 1812 | test "json.test.i_string_invalid_utf-8" { | |
| 1813 | any( | |
| 1814 | \\["ÿ"] | |
| 1815 | ); | |
| 1816 | } | |
| 1817 | ||
| 1818 | test "json.test.i_string_inverted_surrogates_U+1D11E" { | |
| 1819 | any( | |
| 1820 | \\["\uDd1e\uD834"] | |
| 1821 | ); | |
| 1822 | } | |
| 1823 | ||
| 1824 | test "json.test.i_string_iso_latin_1" { | |
| 1825 | any( | |
| 1826 | \\["é"] | |
| 1827 | ); | |
| 1828 | } | |
| 1829 | ||
| 1830 | test "json.test.i_string_lone_second_surrogate" { | |
| 1831 | any( | |
| 1832 | \\["\uDFAA"] | |
| 1833 | ); | |
| 1834 | } | |
| 1835 | ||
| 1836 | test "json.test.i_string_lone_utf8_continuation_byte" { | |
| 1837 | any( | |
| 1838 | \\[""] | |
| 1839 | ); | |
| 1840 | } | |
| 1841 | ||
| 1842 | test "json.test.i_string_not_in_unicode_range" { | |
| 1843 | any( | |
| 1844 | \\["ô¿¿¿"] | |
| 1845 | ); | |
| 1846 | } | |
| 1847 | ||
| 1848 | test "json.test.i_string_overlong_sequence_2_bytes" { | |
| 1849 | any( | |
| 1850 | \\["À¯"] | |
| 1851 | ); | |
| 1852 | } | |
| 1853 | ||
| 1854 | test "json.test.i_string_overlong_sequence_6_bytes" { | |
| 1855 | any( | |
| 1856 | \\["ü¿¿¿¿"] | |
| 1857 | ); | |
| 1858 | } | |
| 1859 | ||
| 1860 | test "json.test.i_string_overlong_sequence_6_bytes_null" { | |
| 1861 | any( | |
| 1862 | \\["ü"] | |
| 1863 | ); | |
| 1864 | } | |
| 1865 | ||
| 1866 | test "json.test.i_string_truncated-utf-8" { | |
| 1867 | any( | |
| 1868 | \\["àÿ"] | |
| 1869 | ); | |
| 1870 | } | |
| 1871 | ||
| 1872 | test "json.test.i_string_utf16BE_no_BOM" { | |
| 1873 | any("\x00\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d"); | |
| 1874 | } | |
| 1875 | ||
| 1876 | test "json.test.i_string_utf16LE_no_BOM" { | |
| 1877 | any("\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d\x00"); | |
| 1878 | } | |
| 1879 | ||
| 1880 | test "json.test.i_string_UTF-16LE_with_BOM" { | |
| 1881 | any("\xc3\xbf\xc3\xbe\x5b\x00\x22\x00\xc3\xa9\x00\x22\x00\x5d\x00"); | |
| 1882 | } | |
| 1883 | ||
| 1884 | test "json.test.i_string_UTF-8_invalid_sequence" { | |
| 1885 | any( | |
| 1886 | \\["æ¥Ñú"] | |
| 1887 | ); | |
| 1888 | } | |
| 1889 | ||
| 1890 | test "json.test.i_string_UTF8_surrogate_U+D800" { | |
| 1891 | any( | |
| 1892 | \\["í "] | |
| 1893 | ); | |
| 1894 | } | |
| 1895 | ||
| 1896 | test "json.test.i_structure_500_nested_arrays" { | |
| 1897 | any(("[" ** 500) ++ ("]" ** 500)); | |
| 1898 | } | |
| 1899 | ||
| 1900 | test "json.test.i_structure_UTF-8_BOM_empty_object" { | |
| 1901 | any( | |
| 1902 | \\{} | |
| 1903 | ); | |
| 1904 | } |