diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-06-29 21:38:32 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-06-29 21:38:32 +0900 |
| commit | cf6972408335a69f2f6cc007f74c6afd316d0d96 (patch) | |
| tree | 8ff7194029e1661cdbf67aaf950552e9f08a673b /mrbgems/mruby-io | |
| parent | ff5ec824fd31bf28e67b0b984d2596a240686cd2 (diff) | |
| parent | a215292b6ad4315a5a0edef49a1df65e3f27b46a (diff) | |
| download | mruby-cf6972408335a69f2f6cc007f74c6afd316d0d96.tar.gz mruby-cf6972408335a69f2f6cc007f74c6afd316d0d96.zip | |
Merge pull request #4540 from dearblue/assert-nesting
Nested `assert` for mrbtest
Diffstat (limited to 'mrbgems/mruby-io')
| -rw-r--r-- | mrbgems/mruby-io/test/io.rb | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb index 5004d0042..1491a4cfe 100644 --- a/mrbgems/mruby-io/test/io.rb +++ b/mrbgems/mruby-io/test/io.rb @@ -4,25 +4,27 @@ MRubyIOTestUtil.io_test_setup $cr, $crlf, $cmd = MRubyIOTestUtil.win? ? [1, "\r\n", "cmd /c "] : [0, "\n", ""] -assert_io_open = ->(meth) do - fd = IO.sysopen($mrbtest_io_rfname) - assert_equal Fixnum, fd.class - io1 = IO.__send__(meth, fd) - begin - assert_equal IO, io1.class - assert_equal $mrbtest_io_msg, io1.read - ensure - io1.close - end +def assert_io_open(meth) + assert do + fd = IO.sysopen($mrbtest_io_rfname) + assert_equal Fixnum, fd.class + io1 = IO.__send__(meth, fd) + begin + assert_equal IO, io1.class + assert_equal $mrbtest_io_msg, io1.read + ensure + 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" + 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 + io2.close unless meth == :open end - io2.close unless meth == :open end assert('IO.class', '15.2.20') do @@ -38,7 +40,7 @@ assert('IO.ancestors', '15.2.20.3') do end assert('IO.open', '15.2.20.4.1') do - assert_io_open.(:open) + assert_io_open(:open) end assert('IO#close', '15.2.20.5.1') do @@ -224,11 +226,11 @@ assert('IO#dup for writable') do end assert('IO.for_fd') do - assert_io_open.(:for_fd) + assert_io_open(:for_fd) end assert('IO.new') do - assert_io_open.(:new) + assert_io_open(:new) end assert('IO gc check') do |
