Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eof check for streaming parser #321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Return `true` if there is a current byte, and `false` if all bytes have been
exausted.
"""
@inline hasmore(ps::MemoryParserState) = ps.s ≤ length(ps)
@inline hasmore(ps::StreamingParserState) = true # no more now ≠ no more ever
@inline hasmore(ps::StreamingParserState) = !ps.used || !eof(ps.io)

"""
Remove as many whitespace bytes as possible from the `ParserState` starting from
Expand Down
2 changes: 2 additions & 0 deletions test/regression/issue314.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@test JSON.parse(IOBuffer("123")) == 123
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to create a new file for this, just add it to e.g.

@testset "Miscellaneous" begin

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I will change this.

@test JSON.parse(IOBuffer("1.5")) == 1.5
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ end
end

@testset "Regression" begin
@testset "for issue #$i" for i in [21, 26, 57, 109, 152, 163]
@testset "for issue #$i" for i in [21, 26, 57, 109, 152, 163, 314]
include("regression/issue$(lpad(string(i), 3, "0")).jl")
end
end
Expand Down