use array parameter on IO.open.

This commit is contained in:
Tomoyuki Sahara
2013-08-30 19:09:36 +09:00
parent 713aa48cf9
commit 47a610e688
2 changed files with 23 additions and 7 deletions
+3 -3
View File
@@ -11,10 +11,10 @@ class IO
BUF_SIZE = 4096
def self.open(fd, mode = "r", opt = {}, &block)
io = self.new(fd, mode, opt)
def self.open(*args, &block)
io = self.new(*args)
return io unless block
return io unless block
begin
yield io
+20 -4
View File
@@ -1,6 +1,10 @@
##
# IO Test
assert('IO TEST SETUP') do
MRubyIOTestUtil.io_test_setup
end
assert('IO', '15.2.20') do
assert_equal(Class, IO.class)
end
@@ -13,6 +17,22 @@ assert('IO', '15.2.20.3') do
assert_include(IO.included_modules, Enumerable)
end
assert('IO.open', '15.2.20.4.1') do
fd = IO.sysopen $mrbtest_io_rfname
assert_equal Fixnum, fd.class
io = IO.open fd
assert_equal IO, io.class
assert_equal $mrbtest_io_msg+"\n", io.read
io.close
fd = IO.sysopen $mrbtest_io_rfname
IO.open(fd) do |io|
assert_equal $mrbtest_io_msg+"\n", io.read
end
true
end
assert('IO.new') do
IO.new(0)
end
@@ -21,10 +41,6 @@ assert('IO gc check') do
100.times { IO.new(0) }
end
assert('IO TEST SETUP') do
MRubyIOTestUtil.io_test_setup
end
assert('IO.sysopen, IO#close, IO#closed?') do
fd = IO.sysopen $mrbtest_io_rfname
assert_equal Fixnum, fd.class