Skip to content

Commit f994915

Browse files
Fix equality definition between byte and Token (#151)
* Fix equality definition between byte and Token * Bump version
1 parent 38615bb commit f994915

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Parsers"
22
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
33
authors = ["quinnj <quinn.jacobd@gmail.com>"]
4-
version = "2.5.0"
4+
version = "2.5.1"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function ==(a::Token, b::Token)
117117
end
118118
end
119119
==(a::Token, b::UInt8) = a.token isa UInt8 && a.token == b
120+
==(a::UInt8, b::Token) = (b == a)
120121
_contains(a::Token, str::String) = _contains(a.token, str)
121122
_contains(a::UInt8, str::String) = a == UInt8(str[1])
122123
_contains(a::Char, str::String) = a == str[1]

test/runtests.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ res = Parsers.xparse(Int64, "1\n"; sentinel=["", " ", " "])
260260
@test res.tlen == 2
261261
@test res.code == (OK | EOF | NEWLINE)
262262

263-
# #140, #142
263+
# #140, #142
264264
res = Parsers.xparse(String, "NA"; sentinel=["NA"])
265265
@test res.code == (SENTINEL | EOF)
266266

@@ -646,6 +646,12 @@ res = Parsers.xparse(String, source, 1 + res.tlen, 0, opt)
646646
buf = UInt8[0x20, 0x20, 0x41, 0x20, 0x20, 0x42, 0x0a, 0x20, 0x20, 0x31, 0x20, 0x20, 0x32, 0x0a, 0x20, 0x20, 0x31, 0x31, 0x20, 0x32, 0x32]
647647
@test Parsers.checkdelim!(buf, 1, 21, Parsers.Options(delim=' ', ignorerepeated=true)) == 3
648648

649+
# #150
650+
@test 0x22 == Parsers.Token(0x22)
651+
@test 0x22 != Parsers.Token(0x00)
652+
@test Parsers.Token(0x22) == 0x22
653+
@test Parsers.Token(0x22) != 0x00
654+
649655
end # @testset "misc"
650656

651657
include("floats.jl")

0 commit comments

Comments
 (0)