mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-io/io.c (io_init): File.new should not take blocks
This commit is contained in:
@@ -706,6 +706,9 @@ io_init(mrb_state *mrb, mrb_value io)
|
||||
|
||||
mode = opt = mrb_nil_value();
|
||||
|
||||
if (mrb_block_given_p(mrb)) {
|
||||
mrb_warn(mrb, "File.new() does not take block; use File.open() instead");
|
||||
}
|
||||
mrb_get_args(mrb, "i|oH", &fd, &mode, &opt);
|
||||
switch (fd) {
|
||||
case 0: /* STDIN_FILENO */
|
||||
|
||||
@@ -16,14 +16,15 @@ def assert_io_open(meth)
|
||||
io1.close
|
||||
end
|
||||
|
||||
io2 = IO.__send__(meth, IO.sysopen($mrbtest_io_rfname))do |io|
|
||||
if meth == :open
|
||||
assert_equal $mrbtest_io_msg, io.read
|
||||
else
|
||||
flunk "IO.#{meth} does not take block"
|
||||
if meth == :open
|
||||
io2 = IO.__send__(meth, IO.sysopen($mrbtest_io_rfname))do |io|
|
||||
if meth == :open
|
||||
assert_equal $mrbtest_io_msg, io.read
|
||||
else
|
||||
flunk "IO.#{meth} does not take block"
|
||||
end
|
||||
end
|
||||
end
|
||||
io2.close unless meth == :open
|
||||
|
||||
assert_raise(RuntimeError) { IO.__send__(meth, 1023) } # For Windows
|
||||
assert_raise(RuntimeError) { IO.__send__(meth, 1 << 26) }
|
||||
|
||||
Reference in New Issue
Block a user