Skip to content

Commit 7a27d55

Browse files
committed
Remove tests for byte oriented read when character buffer is nonempty
There is uncertainty regarding whether or not raising an IOError in such cases is intentional in CRuby. I opened https://bugs.ruby-lang.org/issues/22230 to get confirmation either way, and this commit may be reverted based on the outcome.
1 parent 68eaaf0 commit 7a27d55

8 files changed

Lines changed: 0 additions & 94 deletions

File tree

core/io/getbyte_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@
3232
@io.ungetc(c)
3333
@io.getbyte.should == 86
3434
end
35-
36-
it "raises an exception after ungetc with character conversion" do
37-
@io.set_encoding("utf-8:utf-16be")
38-
c = @io.getc
39-
@io.ungetc(c)
40-
-> do
41-
@io.getbyte
42-
end.should.raise(IOError, "byte oriented read for character buffered IO")
43-
end
4435
end
4536

4637
describe "IO#getbyte" do

core/io/read_nonblock_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,6 @@
6666
@read.read_nonblock(3).should == "bar"
6767
end
6868

69-
it "raises an exception after ungetc with character conversion enabled" do
70-
@write.write("foobar")
71-
@read.set_encoding(
72-
'utf-8', universal_newline: true
73-
)
74-
c = @read.getc
75-
@read.ungetc(c)
76-
-> do
77-
@read.read_nonblock(3)
78-
end.should.raise(IOError, "byte oriented read for character buffered IO")
79-
end
80-
8169
it "returns less data if that is all that is available" do
8270
@write << "hello"
8371
@read.read_nonblock(10).should == "hello"

core/io/read_spec.rb

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,6 @@
686686
@io = IOSpecs.io_fixture "read_euc_jp.txt", "r:euc-jp:utf-8"
687687
end
688688

689-
it "raises an exception after ungetc" do
690-
c = @io.getc
691-
@io.ungetc(c)
692-
-> do
693-
@io.read(2)
694-
end.should.raise(IOError, "byte oriented read for character buffered IO")
695-
end
696-
697689
it_behaves_like :io_read_internal_encoding, nil
698690
it_behaves_like :io_read_size_internal_encoding, nil
699691
end
@@ -703,14 +695,6 @@
703695
@io = IOSpecs.io_fixture "read_euc_jp.txt", mode: "r:euc-jp:utf-8"
704696
end
705697

706-
it "raises an exception after ungetc" do
707-
c = @io.getc
708-
@io.ungetc(c)
709-
-> do
710-
@io.read(2)
711-
end.should.raise(IOError, "byte oriented read for character buffered IO")
712-
end
713-
714698
it_behaves_like :io_read_internal_encoding, nil
715699
it_behaves_like :io_read_size_internal_encoding, nil
716700
end
@@ -723,14 +707,6 @@
723707
@io = IOSpecs.io_fixture "read_euc_jp.txt", options
724708
end
725709

726-
it "raises an exception after ungetc" do
727-
c = @io.getc
728-
@io.ungetc(c)
729-
-> do
730-
@io.read(2)
731-
end.should.raise(IOError, "byte oriented read for character buffered IO")
732-
end
733-
734710
it_behaves_like :io_read_internal_encoding, nil
735711
it_behaves_like :io_read_size_internal_encoding, nil
736712
end
@@ -741,14 +717,6 @@
741717
@io = IOSpecs.io_fixture "read_euc_jp.txt", options
742718
end
743719

744-
it "raises an exception after ungetc" do
745-
c = @io.getc
746-
@io.ungetc(c)
747-
-> do
748-
@io.read(2)
749-
end.should.raise(IOError, "byte oriented read for character buffered IO")
750-
end
751-
752720
it_behaves_like :io_read_internal_encoding, nil
753721
it_behaves_like :io_read_size_internal_encoding, nil
754722
end

core/io/readbyte_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,4 @@
2828
@io.ungetc(c)
2929
@io.readbyte.should == ?r.getbyte(0)
3030
end
31-
32-
it "raises an exception after ungetc with character conversion" do
33-
@io.set_encoding("utf-8:utf-16be")
34-
c = @io.getc
35-
@io.ungetc(c)
36-
-> do
37-
@io.readbyte
38-
end.should.raise(IOError, "byte oriented read for character buffered IO")
39-
end
4031
end

core/io/readpartial_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@
5858
@rd.readpartial(2).should == "b"
5959
end
6060

61-
it "raises an exception after ungetc with character conversion enabled" do
62-
@wr.write("foobar")
63-
@rd.set_encoding('utf-8', 'ascii')
64-
c = @rd.getc
65-
@rd.ungetc(c)
66-
-> do
67-
@rd.readpartial(3)
68-
end.should.raise(IOError, "byte oriented read for character buffered IO")
69-
end
70-
7161
it "discards the existing buffer content upon successful read" do
7262
buffer = +"existing content"
7363
@wr.write("hello world")

core/io/sysread_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@
5757
end.should.raise(IOError, "sysread for buffered IO")
5858
end
5959

60-
it "raises an error when called with a non-empty character buffer" do
61-
@file.set_encoding(Encoding::UTF_8, Encoding::UTF_16BE)
62-
@file.ungetc("a".encode(Encoding::UTF_16BE))
63-
-> do
64-
@file.sysread(5)
65-
end.should.raise(IOError, "byte oriented read for character buffered IO")
66-
end
67-
6860
it "reads normally even when called immediately after a buffered IO#read" do
6961
@file.read(15)
7062
@file.sysread(5).should == "56789"

core/io/sysseek_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@
3333
end.should.raise(IOError, "sysseek for buffered IO")
3434
end
3535

36-
it "raises an error when called with a non-empty character buffer" do
37-
@io.set_encoding(Encoding::UTF_8, Encoding::UTF_16BE)
38-
@io.ungetc("a".encode(Encoding::UTF_16BE))
39-
-> do
40-
@io.sysseek(-5, IO::SEEK_CUR)
41-
end.should.raise(IOError, "sysseek for buffered IO")
42-
end
43-
4436
it "seeks normally even when called immediately after a buffered IO#read" do
4537
@io.read(15)
4638
@io.sysseek(-5, IO::SEEK_CUR).should == 10

core/io/ungetc_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@
9797
@io.pos.should == pos - 1
9898
end
9999

100-
it "makes subsequent unbuffered operations to raise IOError" do
101-
@io.getc
102-
@io.ungetc(100)
103-
-> { @io.sysread(1) }.should.raise(IOError)
104-
end
105-
106100
it "raises TypeError if passed nil" do
107101
@io.getc.should == ?V
108102
proc{@io.ungetc(nil)}.should raise_consistent_error(TypeError, /no implicit conversion of nil into String/)

0 commit comments

Comments
 (0)