IO#read(0) should return "" immediately. fixes iij/mruby-socket#13.

This commit is contained in:
Tomoyuki Sahara
2014-06-19 09:57:08 +09:00
parent d894de86f4
commit ddfc4eb5ef
2 changed files with 11 additions and 5 deletions
+10 -5
View File
@@ -171,11 +171,16 @@ class IO
end
def read(length = nil)
unless length.nil? or length.class == Fixnum
raise TypeError.new "can't convert #{length.class} into Integer"
end
if length && length < 0
raise ArgumentError.new "negative length: #{length} given"
unless length.nil?
unless length.is_a? Fixnum
raise TypeError.new "can't convert #{length.class} into Integer"
end
if length < 0
raise ArgumentError.new "negative length: #{length} given"
end
if length == 0
return "" # easy case
end
end
str = ''