| ... | @@ -12,7 +12,7 @@ const std = @import("../std.zig"); | ... | @@ -12,7 +12,7 @@ const std = @import("../std.zig"); |
| 12 | const json = std.json; | 12 | const json = std.json; |
| 13 | const testing = std.testing; | 13 | const testing = std.testing; |
| 14 | | 14 | |
| 15 | fn testNonStreaming(comptime s: []const u8) !void { | 15 | fn testNonStreaming(s: []const u8) !void { |
| 16 | var p = json.Parser.init(testing.allocator, false); | 16 | var p = json.Parser.init(testing.allocator, false); |
| 17 | defer p.deinit(); | 17 | defer p.deinit(); |
| 18 | | 18 | |
| ... | @@ -20,32 +20,32 @@ fn testNonStreaming(comptime s: []const u8) !void { | ... | @@ -20,32 +20,32 @@ fn testNonStreaming(comptime s: []const u8) !void { |
| 20 | defer tree.deinit(); | 20 | defer tree.deinit(); |
| 21 | } | 21 | } |
| 22 | | 22 | |
| 23 | fn ok(comptime s: []const u8) void { | 23 | fn ok(s: []const u8) !void { |
| 24 | testing.expect(json.validate(s)); | 24 | testing.expect(json.validate(s)); |
| 25 | | 25 | |
| 26 | testNonStreaming(s) catch testing.expect(false); | 26 | try testNonStreaming(s); |
| 27 | } | 27 | } |
| 28 | | 28 | |
| 29 | fn err(comptime s: []const u8) void { | 29 | fn err(s: []const u8) void { |
| 30 | testing.expect(!json.validate(s)); | 30 | testing.expect(!json.validate(s)); |
| 31 | | 31 | |
| 32 | testNonStreaming(s) catch return; | 32 | testNonStreaming(s) catch return; |
| 33 | testing.expect(false); | 33 | testing.expect(false); |
| 34 | } | 34 | } |
| 35 | | 35 | |
| 36 | fn utf8Error(comptime s: []const u8) void { | 36 | fn utf8Error(s: []const u8) void { |
| 37 | testing.expect(!json.validate(s)); | 37 | testing.expect(!json.validate(s)); |
| 38 | | 38 | |
| 39 | testing.expectError(error.InvalidUtf8Byte, testNonStreaming(s)); | 39 | testing.expectError(error.InvalidUtf8Byte, testNonStreaming(s)); |
| 40 | } | 40 | } |
| 41 | | 41 | |
| 42 | fn any(comptime s: []const u8) void { | 42 | fn any(s: []const u8) void { |
| 43 | _ = json.validate(s); | 43 | _ = json.validate(s); |
| 44 | | 44 | |
| 45 | testNonStreaming(s) catch {}; | 45 | testNonStreaming(s) catch {}; |
| 46 | } | 46 | } |
| 47 | | 47 | |
| 48 | fn anyStreamingErrNonStreaming(comptime s: []const u8) void { | 48 | fn anyStreamingErrNonStreaming(s: []const u8) void { |
| 49 | _ = json.validate(s); | 49 | _ = json.validate(s); |
| 50 | | 50 | |
| 51 | testNonStreaming(s) catch return; | 51 | testNonStreaming(s) catch return; |
| ... | @@ -81,7 +81,7 @@ test "y_trailing_comma_after_empty" { | ... | @@ -81,7 +81,7 @@ test "y_trailing_comma_after_empty" { |
| 81 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 81 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 82 | | 82 | |
| 83 | test "y_array_arraysWithSpaces" { | 83 | test "y_array_arraysWithSpaces" { |
| 84 | ok( | 84 | try ok( |
| 85 | \\[[] ] | 85 | \\[[] ] |
| 86 | ); | 86 | ); |
| 87 | } | 87 | } |
| ... | @@ -111,7 +111,7 @@ test "y_array_false" { | ... | @@ -111,7 +111,7 @@ test "y_array_false" { |
| 111 | } | 111 | } |
| 112 | | 112 | |
| 113 | test "y_array_heterogeneous" { | 113 | test "y_array_heterogeneous" { |
| 114 | ok( | 114 | try ok( |
| 115 | \\[null, 1, "1", {}] | 115 | \\[null, 1, "1", {}] |
| 116 | ); | 116 | ); |
| 117 | } | 117 | } |
| ... | @@ -123,14 +123,14 @@ test "y_array_null" { | ... | @@ -123,14 +123,14 @@ test "y_array_null" { |
| 123 | } | 123 | } |
| 124 | | 124 | |
| 125 | test "y_array_with_1_and_newline" { | 125 | test "y_array_with_1_and_newline" { |
| 126 | ok( | 126 | try ok( |
| 127 | \\[1 | 127 | \\[1 |
| 128 | \\] | 128 | \\] |
| 129 | ); | 129 | ); |
| 130 | } | 130 | } |
| 131 | | 131 | |
| 132 | test "y_array_with_leading_space" { | 132 | test "y_array_with_leading_space" { |
| 133 | ok( | 133 | try ok( |
| 134 | \\ [1] | 134 | \\ [1] |
| 135 | ); | 135 | ); |
| 136 | } | 136 | } |
| ... | @@ -142,47 +142,47 @@ test "y_array_with_several_null" { | ... | @@ -142,47 +142,47 @@ test "y_array_with_several_null" { |
| 142 | } | 142 | } |
| 143 | | 143 | |
| 144 | test "y_array_with_trailing_space" { | 144 | test "y_array_with_trailing_space" { |
| 145 | ok("[2] "); | 145 | try ok("[2] "); |
| 146 | } | 146 | } |
| 147 | | 147 | |
| 148 | test "y_number_0e+1" { | 148 | test "y_number_0e+1" { |
| 149 | ok( | 149 | try ok( |
| 150 | \\[0e+1] | 150 | \\[0e+1] |
| 151 | ); | 151 | ); |
| 152 | } | 152 | } |
| 153 | | 153 | |
| 154 | test "y_number_0e1" { | 154 | test "y_number_0e1" { |
| 155 | ok( | 155 | try ok( |
| 156 | \\[0e1] | 156 | \\[0e1] |
| 157 | ); | 157 | ); |
| 158 | } | 158 | } |
| 159 | | 159 | |
| 160 | test "y_number_after_space" { | 160 | test "y_number_after_space" { |
| 161 | ok( | 161 | try ok( |
| 162 | \\[ 4] | 162 | \\[ 4] |
| 163 | ); | 163 | ); |
| 164 | } | 164 | } |
| 165 | | 165 | |
| 166 | test "y_number_double_close_to_zero" { | 166 | test "y_number_double_close_to_zero" { |
| 167 | ok( | 167 | try ok( |
| 168 | \\[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] | 168 | \\[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] |
| 169 | ); | 169 | ); |
| 170 | } | 170 | } |
| 171 | | 171 | |
| 172 | test "y_number_int_with_exp" { | 172 | test "y_number_int_with_exp" { |
| 173 | ok( | 173 | try ok( |
| 174 | \\[20e1] | 174 | \\[20e1] |
| 175 | ); | 175 | ); |
| 176 | } | 176 | } |
| 177 | | 177 | |
| 178 | test "y_number" { | 178 | test "y_number" { |
| 179 | ok( | 179 | try ok( |
| 180 | \\[123e65] | 180 | \\[123e65] |
| 181 | ); | 181 | ); |
| 182 | } | 182 | } |
| 183 | | 183 | |
| 184 | test "y_number_minus_zero" { | 184 | test "y_number_minus_zero" { |
| 185 | ok( | 185 | try ok( |
| 186 | \\[-0] | 186 | \\[-0] |
| 187 | ); | 187 | ); |
| 188 | } | 188 | } |
| ... | @@ -200,49 +200,49 @@ test "y_number_negative_one" { | ... | @@ -200,49 +200,49 @@ test "y_number_negative_one" { |
| 200 | } | 200 | } |
| 201 | | 201 | |
| 202 | test "y_number_negative_zero" { | 202 | test "y_number_negative_zero" { |
| 203 | ok( | 203 | try ok( |
| 204 | \\[-0] | 204 | \\[-0] |
| 205 | ); | 205 | ); |
| 206 | } | 206 | } |
| 207 | | 207 | |
| 208 | test "y_number_real_capital_e" { | 208 | test "y_number_real_capital_e" { |
| 209 | ok( | 209 | try ok( |
| 210 | \\[1E22] | 210 | \\[1E22] |
| 211 | ); | 211 | ); |
| 212 | } | 212 | } |
| 213 | | 213 | |
| 214 | test "y_number_real_capital_e_neg_exp" { | 214 | test "y_number_real_capital_e_neg_exp" { |
| 215 | ok( | 215 | try ok( |
| 216 | \\[1E-2] | 216 | \\[1E-2] |
| 217 | ); | 217 | ); |
| 218 | } | 218 | } |
| 219 | | 219 | |
| 220 | test "y_number_real_capital_e_pos_exp" { | 220 | test "y_number_real_capital_e_pos_exp" { |
| 221 | ok( | 221 | try ok( |
| 222 | \\[1E+2] | 222 | \\[1E+2] |
| 223 | ); | 223 | ); |
| 224 | } | 224 | } |
| 225 | | 225 | |
| 226 | test "y_number_real_exponent" { | 226 | test "y_number_real_exponent" { |
| 227 | ok( | 227 | try ok( |
| 228 | \\[123e45] | 228 | \\[123e45] |
| 229 | ); | 229 | ); |
| 230 | } | 230 | } |
| 231 | | 231 | |
| 232 | test "y_number_real_fraction_exponent" { | 232 | test "y_number_real_fraction_exponent" { |
| 233 | ok( | 233 | try ok( |
| 234 | \\[123.456e78] | 234 | \\[123.456e78] |
| 235 | ); | 235 | ); |
| 236 | } | 236 | } |
| 237 | | 237 | |
| 238 | test "y_number_real_neg_exp" { | 238 | test "y_number_real_neg_exp" { |
| 239 | ok( | 239 | try ok( |
| 240 | \\[1e-2] | 240 | \\[1e-2] |
| 241 | ); | 241 | ); |
| 242 | } | 242 | } |
| 243 | | 243 | |
| 244 | test "y_number_real_pos_exponent" { | 244 | test "y_number_real_pos_exponent" { |
| 245 | ok( | 245 | try ok( |
| 246 | \\[1e+2] | 246 | \\[1e+2] |
| 247 | ); | 247 | ); |
| 248 | } | 248 | } |
| ... | @@ -254,7 +254,7 @@ test "y_number_simple_int" { | ... | @@ -254,7 +254,7 @@ test "y_number_simple_int" { |
| 254 | } | 254 | } |
| 255 | | 255 | |
| 256 | test "y_number_simple_real" { | 256 | test "y_number_simple_real" { |
| 257 | ok( | 257 | try ok( |
| 258 | \\[123.456789] | 258 | \\[123.456789] |
| 259 | ); | 259 | ); |
| 260 | } | 260 | } |
| ... | @@ -266,13 +266,13 @@ test "y_object_basic" { | ... | @@ -266,13 +266,13 @@ test "y_object_basic" { |
| 266 | } | 266 | } |
| 267 | | 267 | |
| 268 | test "y_object_duplicated_key_and_value" { | 268 | test "y_object_duplicated_key_and_value" { |
| 269 | ok( | 269 | try ok( |
| 270 | \\{"a":"b","a":"b"} | 270 | \\{"a":"b","a":"b"} |
| 271 | ); | 271 | ); |
| 272 | } | 272 | } |
| 273 | | 273 | |
| 274 | test "y_object_duplicated_key" { | 274 | test "y_object_duplicated_key" { |
| 275 | ok( | 275 | try ok( |
| 276 | \\{"a":"b","a":"c"} | 276 | \\{"a":"b","a":"c"} |
| 277 | ); | 277 | ); |
| 278 | } | 278 | } |
| ... | @@ -290,25 +290,25 @@ test "y_object_empty_key" { | ... | @@ -290,25 +290,25 @@ test "y_object_empty_key" { |
| 290 | } | 290 | } |
| 291 | | 291 | |
| 292 | test "y_object_escaped_null_in_key" { | 292 | test "y_object_escaped_null_in_key" { |
| 293 | ok( | 293 | try ok( |
| 294 | \\{"foo\u0000bar": 42} | 294 | \\{"foo\u0000bar": 42} |
| 295 | ); | 295 | ); |
| 296 | } | 296 | } |
| 297 | | 297 | |
| 298 | test "y_object_extreme_numbers" { | 298 | test "y_object_extreme_numbers" { |
| 299 | ok( | 299 | try ok( |
| 300 | \\{ "min": -1.0e+28, "max": 1.0e+28 } | 300 | \\{ "min": -1.0e+28, "max": 1.0e+28 } |
| 301 | ); | 301 | ); |
| 302 | } | 302 | } |
| 303 | | 303 | |
| 304 | test "y_object" { | 304 | test "y_object" { |
| 305 | ok( | 305 | try ok( |
| 306 | \\{"asd":"sdf", "dfg":"fgh"} | 306 | \\{"asd":"sdf", "dfg":"fgh"} |
| 307 | ); | 307 | ); |
| 308 | } | 308 | } |
| 309 | | 309 | |
| 310 | test "y_object_long_strings" { | 310 | test "y_object_long_strings" { |
| 311 | ok( | 311 | try ok( |
| 312 | \\{"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} | 312 | \\{"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} |
| 313 | ); | 313 | ); |
| 314 | } | 314 | } |
| ... | @@ -320,13 +320,13 @@ test "y_object_simple" { | ... | @@ -320,13 +320,13 @@ test "y_object_simple" { |
| 320 | } | 320 | } |
| 321 | | 321 | |
| 322 | test "y_object_string_unicode" { | 322 | test "y_object_string_unicode" { |
| 323 | ok( | 323 | try ok( |
| 324 | \\{"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } | 324 | \\{"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } |
| 325 | ); | 325 | ); |
| 326 | } | 326 | } |
| 327 | | 327 | |
| 328 | test "y_object_with_newlines" { | 328 | test "y_object_with_newlines" { |
| 329 | ok( | 329 | try ok( |
| 330 | \\{ | 330 | \\{ |
| 331 | \\"a": "b" | 331 | \\"a": "b" |
| 332 | \\} | 332 | \\} |
| ... | @@ -334,31 +334,31 @@ test "y_object_with_newlines" { | ... | @@ -334,31 +334,31 @@ test "y_object_with_newlines" { |
| 334 | } | 334 | } |
| 335 | | 335 | |
| 336 | test "y_string_1_2_3_bytes_UTF-8_sequences" { | 336 | test "y_string_1_2_3_bytes_UTF-8_sequences" { |
| 337 | ok( | 337 | try ok( |
| 338 | \\["\u0060\u012a\u12AB"] | 338 | \\["\u0060\u012a\u12AB"] |
| 339 | ); | 339 | ); |
| 340 | } | 340 | } |
| 341 | | 341 | |
| 342 | test "y_string_accepted_surrogate_pair" { | 342 | test "y_string_accepted_surrogate_pair" { |
| 343 | ok( | 343 | try ok( |
| 344 | \\["\uD801\udc37"] | 344 | \\["\uD801\udc37"] |
| 345 | ); | 345 | ); |
| 346 | } | 346 | } |
| 347 | | 347 | |
| 348 | test "y_string_accepted_surrogate_pairs" { | 348 | test "y_string_accepted_surrogate_pairs" { |
| 349 | ok( | 349 | try ok( |
| 350 | \\["\ud83d\ude39\ud83d\udc8d"] | 350 | \\["\ud83d\ude39\ud83d\udc8d"] |
| 351 | ); | 351 | ); |
| 352 | } | 352 | } |
| 353 | | 353 | |
| 354 | test "y_string_allowed_escapes" { | 354 | test "y_string_allowed_escapes" { |
| 355 | ok( | 355 | try ok( |
| 356 | \\["\"\\\/\b\f\n\r\t"] | 356 | \\["\"\\\/\b\f\n\r\t"] |
| 357 | ); | 357 | ); |
| 358 | } | 358 | } |
| 359 | | 359 | |
| 360 | test "y_string_backslash_and_u_escaped_zero" { | 360 | test "y_string_backslash_and_u_escaped_zero" { |
| 361 | ok( | 361 | try ok( |
| 362 | \\["\\u0000"] | 362 | \\["\\u0000"] |
| 363 | ); | 363 | ); |
| 364 | } | 364 | } |
| ... | @@ -370,13 +370,13 @@ test "y_string_backslash_doublequotes" { | ... | @@ -370,13 +370,13 @@ test "y_string_backslash_doublequotes" { |
| 370 | } | 370 | } |
| 371 | | 371 | |
| 372 | test "y_string_comments" { | 372 | test "y_string_comments" { |
| 373 | ok( | 373 | try ok( |
| 374 | \\["a/*b*/c/*d//e"] | 374 | \\["a/*b*/c/*d//e"] |
| 375 | ); | 375 | ); |
| 376 | } | 376 | } |
| 377 | | 377 | |
| 378 | test "y_string_double_escape_a" { | 378 | test "y_string_double_escape_a" { |
| 379 | ok( | 379 | try ok( |
| 380 | \\["\\a"] | 380 | \\["\\a"] |
| 381 | ); | 381 | ); |
| 382 | } | 382 | } |
| ... | @@ -388,79 +388,79 @@ test "y_string_double_escape_n" { | ... | @@ -388,79 +388,79 @@ test "y_string_double_escape_n" { |
| 388 | } | 388 | } |
| 389 | | 389 | |
| 390 | test "y_string_escaped_control_character" { | 390 | test "y_string_escaped_control_character" { |
| 391 | ok( | 391 | try ok( |
| 392 | \\["\u0012"] | 392 | \\["\u0012"] |
| 393 | ); | 393 | ); |
| 394 | } | 394 | } |
| 395 | | 395 | |
| 396 | test "y_string_escaped_noncharacter" { | 396 | test "y_string_escaped_noncharacter" { |
| 397 | ok( | 397 | try ok( |
| 398 | \\["\uFFFF"] | 398 | \\["\uFFFF"] |
| 399 | ); | 399 | ); |
| 400 | } | 400 | } |
| 401 | | 401 | |
| 402 | test "y_string_in_array" { | 402 | test "y_string_in_array" { |
| 403 | ok( | 403 | try ok( |
| 404 | \\["asd"] | 404 | \\["asd"] |
| 405 | ); | 405 | ); |
| 406 | } | 406 | } |
| 407 | | 407 | |
| 408 | test "y_string_in_array_with_leading_space" { | 408 | test "y_string_in_array_with_leading_space" { |
| 409 | ok( | 409 | try ok( |
| 410 | \\[ "asd"] | 410 | \\[ "asd"] |
| 411 | ); | 411 | ); |
| 412 | } | 412 | } |
| 413 | | 413 | |
| 414 | test "y_string_last_surrogates_1_and_2" { | 414 | test "y_string_last_surrogates_1_and_2" { |
| 415 | ok( | 415 | try ok( |
| 416 | \\["\uDBFF\uDFFF"] | 416 | \\["\uDBFF\uDFFF"] |
| 417 | ); | 417 | ); |
| 418 | } | 418 | } |
| 419 | | 419 | |
| 420 | test "y_string_nbsp_uescaped" { | 420 | test "y_string_nbsp_uescaped" { |
| 421 | ok( | 421 | try ok( |
| 422 | \\["new\u00A0line"] | 422 | \\["new\u00A0line"] |
| 423 | ); | 423 | ); |
| 424 | } | 424 | } |
| 425 | | 425 | |
| 426 | test "y_string_nonCharacterInUTF-8_U+10FFFF" { | 426 | test "y_string_nonCharacterInUTF-8_U+10FFFF" { |
| 427 | ok( | 427 | try ok( |
| 428 | \\[""] | 428 | \\[""] |
| 429 | ); | 429 | ); |
| 430 | } | 430 | } |
| 431 | | 431 | |
| 432 | test "y_string_nonCharacterInUTF-8_U+FFFF" { | 432 | test "y_string_nonCharacterInUTF-8_U+FFFF" { |
| 433 | ok( | 433 | try ok( |
| 434 | \\[""] | 434 | \\[""] |
| 435 | ); | 435 | ); |
| 436 | } | 436 | } |
| 437 | | 437 | |
| 438 | test "y_string_null_escape" { | 438 | test "y_string_null_escape" { |
| 439 | ok( | 439 | try ok( |
| 440 | \\["\u0000"] | 440 | \\["\u0000"] |
| 441 | ); | 441 | ); |
| 442 | } | 442 | } |
| 443 | | 443 | |
| 444 | test "y_string_one-byte-utf-8" { | 444 | test "y_string_one-byte-utf-8" { |
| 445 | ok( | 445 | try ok( |
| 446 | \\["\u002c"] | 446 | \\["\u002c"] |
| 447 | ); | 447 | ); |
| 448 | } | 448 | } |
| 449 | | 449 | |
| 450 | test "y_string_pi" { | 450 | test "y_string_pi" { |
| 451 | ok( | 451 | try ok( |
| 452 | \\["π"] | 452 | \\["π"] |
| 453 | ); | 453 | ); |
| 454 | } | 454 | } |
| 455 | | 455 | |
| 456 | test "y_string_reservedCharacterInUTF-8_U+1BFFF" { | 456 | test "y_string_reservedCharacterInUTF-8_U+1BFFF" { |
| 457 | ok( | 457 | try ok( |
| 458 | \\[""] | 458 | \\[""] |
| 459 | ); | 459 | ); |
| 460 | } | 460 | } |
| 461 | | 461 | |
| 462 | test "y_string_simple_ascii" { | 462 | test "y_string_simple_ascii" { |
| 463 | ok( | 463 | try ok( |
| 464 | \\["asd "] | 464 | \\["asd "] |
| 465 | ); | 465 | ); |
| 466 | } | 466 | } |
| ... | @@ -472,115 +472,115 @@ test "y_string_space" { | ... | @@ -472,115 +472,115 @@ test "y_string_space" { |
| 472 | } | 472 | } |
| 473 | | 473 | |
| 474 | test "y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF" { | 474 | test "y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF" { |
| 475 | ok( | 475 | try ok( |
| 476 | \\["\uD834\uDd1e"] | 476 | \\["\uD834\uDd1e"] |
| 477 | ); | 477 | ); |
| 478 | } | 478 | } |
| 479 | | 479 | |
| 480 | test "y_string_three-byte-utf-8" { | 480 | test "y_string_three-byte-utf-8" { |
| 481 | ok( | 481 | try ok( |
| 482 | \\["\u0821"] | 482 | \\["\u0821"] |
| 483 | ); | 483 | ); |
| 484 | } | 484 | } |
| 485 | | 485 | |
| 486 | test "y_string_two-byte-utf-8" { | 486 | test "y_string_two-byte-utf-8" { |
| 487 | ok( | 487 | try ok( |
| 488 | \\["\u0123"] | 488 | \\["\u0123"] |
| 489 | ); | 489 | ); |
| 490 | } | 490 | } |
| 491 | | 491 | |
| 492 | test "y_string_u+2028_line_sep" { | 492 | test "y_string_u+2028_line_sep" { |
| 493 | ok("[\"\xe2\x80\xa8\"]"); | 493 | try ok("[\"\xe2\x80\xa8\"]"); |
| 494 | } | 494 | } |
| 495 | | 495 | |
| 496 | test "y_string_u+2029_par_sep" { | 496 | test "y_string_u+2029_par_sep" { |
| 497 | ok("[\"\xe2\x80\xa9\"]"); | 497 | try ok("[\"\xe2\x80\xa9\"]"); |
| 498 | } | 498 | } |
| 499 | | 499 | |
| 500 | test "y_string_uescaped_newline" { | 500 | test "y_string_uescaped_newline" { |
| 501 | ok( | 501 | try ok( |
| 502 | \\["new\u000Aline"] | 502 | \\["new\u000Aline"] |
| 503 | ); | 503 | ); |
| 504 | } | 504 | } |
| 505 | | 505 | |
| 506 | test "y_string_uEscape" { | 506 | test "y_string_uEscape" { |
| 507 | ok( | 507 | try ok( |
| 508 | \\["\u0061\u30af\u30EA\u30b9"] | 508 | \\["\u0061\u30af\u30EA\u30b9"] |
| 509 | ); | 509 | ); |
| 510 | } | 510 | } |
| 511 | | 511 | |
| 512 | test "y_string_unescaped_char_delete" { | 512 | test "y_string_unescaped_char_delete" { |
| 513 | ok("[\"\x7f\"]"); | 513 | try ok("[\"\x7f\"]"); |
| 514 | } | 514 | } |
| 515 | | 515 | |
| 516 | test "y_string_unicode_2" { | 516 | test "y_string_unicode_2" { |
| 517 | ok( | 517 | try ok( |
| 518 | \\["⍂㈴⍂"] | 518 | \\["⍂㈴⍂"] |
| 519 | ); | 519 | ); |
| 520 | } | 520 | } |
| 521 | | 521 | |
| 522 | test "y_string_unicodeEscapedBackslash" { | 522 | test "y_string_unicodeEscapedBackslash" { |
| 523 | ok( | 523 | try ok( |
| 524 | \\["\u005C"] | 524 | \\["\u005C"] |
| 525 | ); | 525 | ); |
| 526 | } | 526 | } |
| 527 | | 527 | |
| 528 | test "y_string_unicode_escaped_double_quote" { | 528 | test "y_string_unicode_escaped_double_quote" { |
| 529 | ok( | 529 | try ok( |
| 530 | \\["\u0022"] | 530 | \\["\u0022"] |
| 531 | ); | 531 | ); |
| 532 | } | 532 | } |
| 533 | | 533 | |
| 534 | test "y_string_unicode" { | 534 | test "y_string_unicode" { |
| 535 | ok( | 535 | try ok( |
| 536 | \\["\uA66D"] | 536 | \\["\uA66D"] |
| 537 | ); | 537 | ); |
| 538 | } | 538 | } |
| 539 | | 539 | |
| 540 | test "y_string_unicode_U+10FFFE_nonchar" { | 540 | test "y_string_unicode_U+10FFFE_nonchar" { |
| 541 | ok( | 541 | try ok( |
| 542 | \\["\uDBFF\uDFFE"] | 542 | \\["\uDBFF\uDFFE"] |
| 543 | ); | 543 | ); |
| 544 | } | 544 | } |
| 545 | | 545 | |
| 546 | test "y_string_unicode_U+1FFFE_nonchar" { | 546 | test "y_string_unicode_U+1FFFE_nonchar" { |
| 547 | ok( | 547 | try ok( |
| 548 | \\["\uD83F\uDFFE"] | 548 | \\["\uD83F\uDFFE"] |
| 549 | ); | 549 | ); |
| 550 | } | 550 | } |
| 551 | | 551 | |
| 552 | test "y_string_unicode_U+200B_ZERO_WIDTH_SPACE" { | 552 | test "y_string_unicode_U+200B_ZERO_WIDTH_SPACE" { |
| 553 | ok( | 553 | try ok( |
| 554 | \\["\u200B"] | 554 | \\["\u200B"] |
| 555 | ); | 555 | ); |
| 556 | } | 556 | } |
| 557 | | 557 | |
| 558 | test "y_string_unicode_U+2064_invisible_plus" { | 558 | test "y_string_unicode_U+2064_invisible_plus" { |
| 559 | ok( | 559 | try ok( |
| 560 | \\["\u2064"] | 560 | \\["\u2064"] |
| 561 | ); | 561 | ); |
| 562 | } | 562 | } |
| 563 | | 563 | |
| 564 | test "y_string_unicode_U+FDD0_nonchar" { | 564 | test "y_string_unicode_U+FDD0_nonchar" { |
| 565 | ok( | 565 | try ok( |
| 566 | \\["\uFDD0"] | 566 | \\["\uFDD0"] |
| 567 | ); | 567 | ); |
| 568 | } | 568 | } |
| 569 | | 569 | |
| 570 | test "y_string_unicode_U+FFFE_nonchar" { | 570 | test "y_string_unicode_U+FFFE_nonchar" { |
| 571 | ok( | 571 | try ok( |
| 572 | \\["\uFFFE"] | 572 | \\["\uFFFE"] |
| 573 | ); | 573 | ); |
| 574 | } | 574 | } |
| 575 | | 575 | |
| 576 | test "y_string_utf8" { | 576 | test "y_string_utf8" { |
| 577 | ok( | 577 | try ok( |
| 578 | \\["€𝄞"] | 578 | \\["€𝄞"] |
| 579 | ); | 579 | ); |
| 580 | } | 580 | } |
| 581 | | 581 | |
| 582 | test "y_string_with_del_character" { | 582 | test "y_string_with_del_character" { |
| 583 | ok("[\"a\x7fa\"]"); | 583 | try ok("[\"a\x7fa\"]"); |
| 584 | } | 584 | } |
| 585 | | 585 | |
| 586 | test "y_structure_lonely_false" { | 586 | test "y_structure_lonely_false" { |
| ... | @@ -596,7 +596,7 @@ test "y_structure_lonely_int" { | ... | @@ -596,7 +596,7 @@ test "y_structure_lonely_int" { |
| 596 | } | 596 | } |
| 597 | | 597 | |
| 598 | test "y_structure_lonely_negative_real" { | 598 | test "y_structure_lonely_negative_real" { |
| 599 | ok( | 599 | try ok( |
| 600 | \\-0.1 | 600 | \\-0.1 |
| 601 | ); | 601 | ); |
| 602 | } | 602 | } |
| ... | @@ -638,7 +638,7 @@ test "y_structure_true_in_array" { | ... | @@ -638,7 +638,7 @@ test "y_structure_true_in_array" { |
| 638 | } | 638 | } |
| 639 | | 639 | |
| 640 | test "y_structure_whitespace_array" { | 640 | test "y_structure_whitespace_array" { |
| 641 | ok(" [] "); | 641 | try ok(" [] "); |
| 642 | } | 642 | } |
| 643 | | 643 | |
| 644 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 644 | //////////////////////////////////////////////////////////////////////////////////////////////////// |