Commit 3642fe40 authored by Christopher Aue's avatar Christopher Aue

fixed #87: IO#read(n) with n > IO::BUF_SIZE

parent fe99819b
......@@ -205,10 +205,12 @@ class IO
break
end
if length && length <= @buf.size
array.push @buf[0, length]
@buf = @buf[length, @buf.size - length]
break
if length
consume = (length <= @buf.size) ? length : @buf.size
array.push @buf[0, consume]
@buf = @buf[consume, @buf.size - consume]
length -= consume
break if length == 0
else
array.push @buf
@buf = ''
......
......@@ -140,6 +140,13 @@ assert('IO#read', '15.2.20.5.14') do
end
end
assert "IO#read(n) with n > IO::BUF_SIZE" do
r,w = IO.pipe
n = IO::BUF_SIZE+1
w.write 'a'*n
assert_equal r.read(n), 'a'*n
end
assert('IO#readchar', '15.2.20.5.15') do
# almost same as IO#getc
IO.open(IO.sysopen($mrbtest_io_rfname)) do |io|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment