mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add IO#getbyte
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
44d5e214cc
commit
bf455fd582
@@ -59,7 +59,7 @@ Add the line below to your build configuration.
|
||||
| IO#fileno, IO#to_i | o | |
|
||||
| IO#flush | o | |
|
||||
| IO#fsync | | |
|
||||
| IO#getbyte | | |
|
||||
| IO#getbyte | o | |
|
||||
| IO#getc | o | |
|
||||
| IO#gets | o | |
|
||||
| IO#internal_encoding | | |
|
||||
@@ -93,7 +93,7 @@ Add the line below to your build configuration.
|
||||
| IO#sysseek | o | |
|
||||
| IO#syswrite | o | |
|
||||
| IO#to_io | | |
|
||||
| IO#ungetbyte | | |
|
||||
| IO#ungetbyte | o | |
|
||||
| IO#ungetc | o | |
|
||||
| IO#write | o | |
|
||||
| IO#write_nonblock | | |
|
||||
|
||||
@@ -184,6 +184,11 @@ class IO
|
||||
nil
|
||||
end
|
||||
|
||||
def ungetbyte(substr)
|
||||
substr = substr.chr if substr.is_a? Integer
|
||||
ungetc substr
|
||||
end
|
||||
|
||||
def read(length = nil, outbuf = "")
|
||||
unless length.nil?
|
||||
unless length.is_a? Integer
|
||||
@@ -296,6 +301,12 @@ class IO
|
||||
end
|
||||
end
|
||||
|
||||
def getbyte
|
||||
ret = getc
|
||||
return ret.getbyte 0 if ret
|
||||
ret
|
||||
end
|
||||
|
||||
# 15.2.20.5.3
|
||||
def each(&block)
|
||||
return to_enum unless block
|
||||
|
||||
@@ -105,6 +105,15 @@ assert('IO#getc', '15.2.20.5.8') do
|
||||
io.close
|
||||
end
|
||||
|
||||
assert('IO#getbyte') do
|
||||
io = IO.new(IO.sysopen($mrbtest_io_rfname))
|
||||
$mrbtest_io_msg.split("").each do |ch|
|
||||
assert_equal ch.getbyte(0), io.getbyte
|
||||
end
|
||||
assert_equal nil, io.getbyte
|
||||
io.close
|
||||
end
|
||||
|
||||
#assert('IO#gets', '15.2.20.5.9') do
|
||||
#assert('IO#initialize_copy', '15.2.20.5.10') do
|
||||
#assert('IO#print', '15.2.20.5.11') do
|
||||
|
||||
Reference in New Issue
Block a user