mruby-io/io.c (io_init): File.new should not take blocks

This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-05-23 15:33:33 +09:00
parent 67187881c2
commit 53de96426a
2 changed files with 10 additions and 6 deletions
+3
View File
@@ -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 */
+7 -6
View File
@@ -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) }