parent
229ba1215f
commit
54499d7810
Notes:
git
2025-06-06 00:31:58 +00:00
1
io.c
1
io.c
@ -4350,7 +4350,6 @@ rb_io_ungetc(VALUE io, VALUE c)
|
|||||||
|
|
||||||
GetOpenFile(io, fptr);
|
GetOpenFile(io, fptr);
|
||||||
rb_io_check_char_readable(fptr);
|
rb_io_check_char_readable(fptr);
|
||||||
if (NIL_P(c)) return Qnil;
|
|
||||||
if (FIXNUM_P(c)) {
|
if (FIXNUM_P(c)) {
|
||||||
c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr));
|
c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr));
|
||||||
}
|
}
|
||||||
|
@ -103,11 +103,20 @@ describe "IO#ungetc" do
|
|||||||
-> { @io.sysread(1) }.should raise_error(IOError)
|
-> { @io.sysread(1) }.should raise_error(IOError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ruby_version_is "0"..."2.8" do
|
||||||
it "does not affect the stream and returns nil when passed nil" do
|
it "does not affect the stream and returns nil when passed nil" do
|
||||||
@io.getc.should == ?V
|
@io.getc.should == ?V
|
||||||
@io.ungetc(nil)
|
@io.ungetc(nil)
|
||||||
@io.getc.should == ?o
|
@io.getc.should == ?o
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ruby_version_is "2.8" 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
|
it "puts one or more characters back in the stream" do
|
||||||
@io.gets
|
@io.gets
|
||||||
|
Loading…
x
Reference in New Issue
Block a user