mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
IO#sysread should raise IOError when closed
This commit is contained in:
@@ -636,7 +636,7 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
|
||||
buf = mrb_str_resize(mrb, buf, maxlen);
|
||||
}
|
||||
|
||||
fptr = (struct mrb_io *)mrb_get_datatype(mrb, io, &mrb_io_type);
|
||||
fptr = (struct mrb_io *)io_get_open_fptr(mrb, io);
|
||||
ret = read(fptr->fd, RSTRING_PTR(buf), maxlen);
|
||||
switch (ret) {
|
||||
case 0: /* EOF */
|
||||
|
||||
@@ -235,6 +235,7 @@ assert('IO.sysopen, IO#sysread') do
|
||||
end
|
||||
io.close
|
||||
assert_equal "", io.sysread(0)
|
||||
assert_raise(IOError) { io.sysread(1) }
|
||||
io.closed?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user