diff options
Diffstat (limited to 'spec/ruby/core/io/readpartial_spec.rb')
-rw-r--r-- | spec/ruby/core/io/readpartial_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/ruby/core/io/readpartial_spec.rb b/spec/ruby/core/io/readpartial_spec.rb index 2b33a0d5b1..0852f20b2d 100644 --- a/spec/ruby/core/io/readpartial_spec.rb +++ b/spec/ruby/core/io/readpartial_spec.rb @@ -59,10 +59,10 @@ describe "IO#readpartial" do end it "discards the existing buffer content upon successful read" do - buffer = "existing" + buffer = +"existing content" @wr.write("hello world") @wr.close - @rd.readpartial(11, buffer) + @rd.readpartial(11, buffer).should.equal?(buffer) buffer.should == "hello world" end @@ -74,7 +74,7 @@ describe "IO#readpartial" do end it "discards the existing buffer content upon error" do - buffer = 'hello' + buffer = +'hello' @wr.close -> { @rd.readpartial(1, buffer) }.should raise_error(EOFError) buffer.should be_empty @@ -93,4 +93,20 @@ describe "IO#readpartial" do @rd.readpartial(0).should == "" end + ruby_bug "#18421", ""..."3.0.4" do + it "clears and returns the given buffer if the length argument is 0" do + buffer = +"existing content" + @rd.readpartial(0, buffer).should == buffer + buffer.should == "" + end + end + + it "preserves the encoding of the given buffer" do + buffer = ''.encode(Encoding::ISO_8859_1) + @wr.write("abc") + @wr.close + @rd.readpartial(10, buffer) + + buffer.encoding.should == Encoding::ISO_8859_1 + end end |