diff --git a/src/stream.jl b/src/stream.jl index 0fca6026..2300e6bc 100644 --- a/src/stream.jl +++ b/src/stream.jl @@ -282,9 +282,10 @@ end # --------------- function Base.seekstart(stream::TranscodingStream) + checkmode(stream) mode = stream.state.mode - @checkmode (:idle, :read, :write) - if mode == :read || mode == :write + @checkmode (:idle, :read) + if mode == :read callstartproc(stream, mode) emptybuffer!(stream.state.buffer1) emptybuffer!(stream.state.buffer2) diff --git a/test/codecquadruple.jl b/test/codecquadruple.jl index 18a40753..b3d710e4 100644 --- a/test/codecquadruple.jl +++ b/test/codecquadruple.jl @@ -113,14 +113,10 @@ end stream = TranscodingStream(QuadrupleCodec(), sink, bufsize=16) write(stream, "x") # seekstart must not delete user data even if it errors. - try - seekstart(stream) - catch e - e isa ArgumentError || rethrow() - end + @test_throws ArgumentError seekstart(stream) write(stream, TranscodingStreams.TOKEN_END) flush(stream) - @test_broken take!(sink) == b"xxxx" + @test take!(sink) == b"xxxx" close(stream) end end