Bug #13675 ยป io-ungetc-nil-13675.patch
io.c | ||
---|---|---|
GetOpenFile(io, fptr);
|
||
rb_io_check_char_readable(fptr);
|
||
if (NIL_P(c)) return Qnil;
|
||
if (FIXNUM_P(c)) {
|
||
c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr));
|
||
}
|
spec/ruby/core/io/ungetc_spec.rb | ||
---|---|---|
-> { @io.sysread(1) }.should raise_error(IOError)
|
||
end
|
||
it "does not affect the stream and returns nil when passed nil" do
|
||
@io.getc.should == ?V
|
||
@io.ungetc(nil)
|
||
@io.getc.should == ?o
|
||
ruby_version_is "0"..."2.7" do
|
||
it "does not affect the stream and returns nil when passed nil" do
|
||
@io.getc.should == ?V
|
||
@io.ungetc(nil)
|
||
@io.getc.should == ?o
|
||
end
|
||
end
|
||
ruby_version_is "2.7" do
|
||
it "raises TypeError if passed nil" do
|
||
@io.getc.should == ?V
|
||
proc{@io.ungetc(nil)}.should raise_error(TypeError)
|
||
end
|
||
end
|
||
it "puts one or more characters back in the stream" do
|