Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Mar 22, 2024
1 parent 96d5147 commit bc5532d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/noop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function fillbuffer(stream::NoopStream; eager::Bool = false)
changemode!(stream, :read)
buffer = stream.buffer1
@assert buffer === stream.buffer2
if stream.stream isa TranscodingStream && buffer === stream.buffer1
if stream.stream isa TranscodingStream && buffer === stream.stream.buffer1
# Delegate the operation when buffers are shared.
return fillbuffer(stream.stream, eager = eager)
end
Expand Down
13 changes: 13 additions & 0 deletions test/codecnoop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@
@test read(stream) == b"foobar"
close(stream)

stream = NoopStream(NoopStream(IOBuffer("foobar")); sharedbuf=false)
@test read(stream) == b"foobar"
close(stream)

stream = NoopStream(NoopStream(IOBuffer("foobar")); sharedbuf=false)
@test map(x->read(stream, UInt8), 1:6) == b"foobar"
@test eof(stream)
close(stream)

stream = NoopStream(NoopStream(NoopStream(IOBuffer("foobar")); sharedbuf=false))
@test read(stream) == b"foobar"
close(stream)

# Two buffers are the same object.
stream = NoopStream(IOBuffer("foo"))
@test stream.buffer1 === stream.buffer2
Expand Down

0 comments on commit bc5532d

Please sign in to comment.