IO#sysread should raise error when invalid pos
MODIFY
src/io.c
src/io.c
@@ -623,7 +623,7 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
mrb_get_args(mrb, "i|S", &maxlen, &buf);
if (maxlen < 0) {
- return mrb_nil_value();
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "negative expanding string size");
}
else if (maxlen == 0) {
return mrb_str_new(mrb, NULL, maxlen);

MODIFY
test/io.rb
test/io.rb
@@ -236,6 +236,7 @@ assert('IO.sysopen, IO#sysread') do
io.close
assert_equal "", io.sysread(0)
assert_raise(IOError) { io.sysread(1) }
+ assert_raise(ArgumentError) { io.sysread(-1) }
io.closed?
end

IO#sysread should raise error when invalid pos