Skip to content

Commit 793e71f

Browse files
authored
Fixes for Parsers changes (#54)
* fix tests * fix tests again
1 parent dcd643b commit 793e71f

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

test/runtests.jl

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,19 +346,19 @@ testcases = [
346346
(" \" \" ", InlineString7(" "), NamedTuple(), OK | QUOTED | EOF), # quoted
347347
("NA", InlineString7(), (; sentinel=["NA"]), EOF | SENTINEL), # sentinel
348348
("\"\"", InlineString7(), NamedTuple(), OK | QUOTED | EOF), # same e & cq
349-
("\"\",", InlineString7(), NamedTuple(), OK | QUOTED | EOF | DELIMITED), # same e & cq
349+
("\"\",", InlineString7(), NamedTuple(), OK | QUOTED | DELIMITED), # same e & cq
350350
("\"\"\"\"", InlineString7("\""), NamedTuple(), OK | QUOTED | ESCAPED_STRING | EOF), # same e & cq
351-
("\"\\", InlineString7(), (; escapechar=UInt8('\\')), OK | QUOTED | INVALID_QUOTED_FIELD | EOF), # \\ e, invalid quoted
351+
("\"\\", InlineString7(), (; escapechar=UInt8('\\')), OK | QUOTED | ESCAPED_STRING | INVALID_QUOTED_FIELD | EOF), # \\ e, invalid quoted
352352
("\"\\\"\"", InlineString7("\""), (; escapechar=UInt8('\\')), OK | QUOTED | ESCAPED_STRING | EOF), # \\ e, valid
353353
("\"\"", InlineString7(), (; escapechar=UInt8('\\')), OK | QUOTED | EOF), # diff e & cq
354-
("\"a", InlineString7(), NamedTuple(), OK | QUOTED | INVALID_QUOTED_FIELD | EOF), # invalid quoted
354+
("\"a", InlineString7("a"), NamedTuple(), OK | QUOTED | INVALID_QUOTED_FIELD | EOF), # invalid quoted
355355
("\"a\"", InlineString7("a"), NamedTuple(), OK | QUOTED | EOF), # quoted
356356
("\"a\" ", InlineString7("a"), NamedTuple(), OK | QUOTED | EOF), # quoted
357-
("\"a\",", InlineString7("a"), NamedTuple(), OK | QUOTED | EOF | DELIMITED), # quoted
358-
("a,", InlineString7("a"), NamedTuple(), OK | EOF | DELIMITED),
359-
("a__", InlineString7("a"), (; delim="__"), OK | EOF | DELIMITED),
360-
("a,", InlineString7("a"), (; ignorerepeated=true), OK | EOF | DELIMITED),
361-
("a__", InlineString7("a"), (; delim="__", ignorerepeated=true), OK | EOF | DELIMITED),
357+
("\"a\",", InlineString7("a"), NamedTuple(), OK | QUOTED | DELIMITED), # quoted
358+
("a,", InlineString7("a"), NamedTuple(), OK | DELIMITED),
359+
("a__", InlineString7("a"), (; delim="__"), OK | DELIMITED),
360+
("a,", InlineString7("a"), (; ignorerepeated=true), OK | DELIMITED),
361+
("a__", InlineString7("a"), (; delim="__", ignorerepeated=true), OK | DELIMITED),
362362
("a\n", InlineString7("a"), (; ignorerepeated=true), OK | NEWLINE | EOF),
363363
("a\r", InlineString7("a"), (; ignorerepeated=true), OK | NEWLINE | EOF),
364364
("a\r\n", InlineString7("a"), (; ignorerepeated=true), OK | NEWLINE | EOF),
@@ -381,8 +381,20 @@ for (i, case) in enumerate(testcases)
381381
println("testing case = $i")
382382
buf, check, opts, checkcode = case
383383
res = Parsers.xparse(InlineString7, buf; opts...)
384-
@test check === res.val
385-
@test checkcode == res.code
384+
# in Parsers.jl pre-v2.5, we failed to include the string value on INVALID
385+
@test check === res.val || (i == 14 && res.val === InlineString7(""))
386+
if Parsers.ok(checkcode) && Parsers.delimited(checkcode) && !Parsers.newline(checkcode)
387+
# due to a Parsers.jl bug in pre-v2.5, String parsing inaccurately included the
388+
# EOF code when it shouldn't have; so we allow either in our tests.
389+
code = res.code & ~EOF
390+
elseif i == 11
391+
# due to a Parsers.jl bug in pre-v2.5, String parsing failed to include the
392+
# ESCAPED_STRING code when it should have
393+
code = res.code | ESCAPED_STRING
394+
else
395+
code = res.code
396+
end
397+
@test checkcode == code
386398
end
387399

388400
res = Parsers.xparse(InlineString1, "")

0 commit comments

Comments
 (0)