ruby-changes:40197
From: nobu <ko1@a...>
Date: Sun, 25 Oct 2015 16:54:16 +0900 (JST)
Subject: [ruby-changes:40197] nobu:r52278 (trunk): test_io.rb: assert_separately
nobu 2015-10-25 16:54:07 +0900 (Sun, 25 Oct 2015) New Revision: 52278 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52278 Log: test_io.rb: assert_separately * test/ruby/test_io.rb (test_dup_many, test_set_lineno): use assert_separately for more descriptive messages. Modified files: trunk/test/ruby/test_io.rb Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 52277) +++ test/ruby/test_io.rb (revision 52278) @@ -1136,29 +1136,19 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1136 end def test_dup_many - ruby('-e', <<-'End') {|f| + assert_separately([], <<-'End') if defined?(Process::RLIMIT_NOFILE) lim = Process.getrlimit(Process::RLIMIT_NOFILE)[0] Process.setrlimit(Process::RLIMIT_NOFILE, [lim, 1024].min) end - ok = 0 a = [] - begin + assert_raise(Errno::EMFILE, Errno::ENFILE, Errno::ENOMEM) do loop {a << IO.pipe} - rescue Errno::EMFILE, Errno::ENFILE, Errno::ENOMEM - ok += 1 end - print "no" if ok != 1 - begin + assert_raise(Errno::EMFILE, Errno::ENFILE, Errno::ENOMEM) do loop {a << [a[-1][0].dup, a[-1][1].dup]} - rescue Errno::EMFILE, Errno::ENFILE, Errno::ENOMEM - ok += 1 end - print "no" if ok != 2 - print "ok" End - assert_equal("ok", f.read) - } end def test_inspect @@ -1503,23 +1493,21 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1493 def test_set_lineno make_tempfile {|t| - ruby("-e", <<-SRC, t.path) do |f| + assert_separately(["-", t.path], <<-SRC) open(ARGV[0]) do |f| - p $. - f.gets; p $. - f.gets; p $. - f.lineno = 1000; p $. - f.gets; p $. - f.gets; p $. - f.rewind; p $. - f.gets; p $. - f.gets; p $. - f.gets; p $. - f.gets; p $. + assert_equal(0, $.) + f.gets; assert_equal(1, $.) + f.gets; assert_equal(2, $.) + f.lineno = 1000; assert_equal(2, $.) + f.gets; assert_equal(1001, $.) + f.gets; assert_equal(1001, $.) + f.rewind; assert_equal(1001, $.) + f.gets; assert_equal(1, $.) + f.gets; assert_equal(2, $.) + f.gets; assert_equal(3, $.) + f.gets; assert_equal(3, $.) end SRC - assert_equal("0,1,2,2,1001,1001,1001,1,2,3,3", f.read.chomp.gsub("\n", ",")) - end pipe(proc do |w| w.puts "foo" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/