Skip to content

Commit

Permalink
fixup! Always read unbuffered when IO::Buffered#sync = true
Browse files Browse the repository at this point in the history
  • Loading branch information
RX14 committed May 4, 2018
1 parent 1283bfb commit 2817969
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spec/std/io/buffered_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ describe "IO::Buffered" do
end

it "works with IO#read (already buffered)" do
str = IO::Memory.new "#{"a" * IO::Buffered::BUFFER_SIZE}bcde"
str = IO::Memory.new
str << "a" * IO::Buffered::BUFFER_SIZE
str.pos = 0

io = BufferedWrapper.new(str)
io.sync?.should be_false
Expand All @@ -331,6 +333,9 @@ describe "IO::Buffered" do
io.sync = true
io.sync?.should be_true

str << "bcde"
str.pos -= 4

byte = Bytes.new(1)
io.read_fully(byte)
byte[0].should eq('b'.ord.to_u8)
Expand All @@ -352,8 +357,10 @@ describe "IO::Buffered" do
str.gets_to_end.should eq("bc")
end

it "works with IO#read (already buffered)" do
str = IO::Memory.new "#{"a" * IO::Buffered::BUFFER_SIZE}bcde"
it "works with IO#read_byte (already buffered)" do
str = IO::Memory.new
str << "a" * IO::Buffered::BUFFER_SIZE
str.pos = 0

io = BufferedWrapper.new(str)
io.sync?.should be_false
Expand All @@ -365,6 +372,9 @@ describe "IO::Buffered" do
io.sync = true
io.sync?.should be_true

str << "bcde"
str.pos -= 4

io.read_byte.should eq('b'.ord.to_u8)

str.gets_to_end.should eq("cde")
Expand Down

0 comments on commit 2817969

Please sign in to comment.