diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-25 07:54:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-25 07:54:07 +0000 |
commit | ef3aaed8c7789a2837141746ad653dc209a62918 (patch) | |
tree | 5401eb23b26d685a0a938e0c8194cf05329801c2 /test | |
parent | 837471aac32c1728dd04135ec2c10f6e1c376e90 (diff) | |
download | ruby-ef3aaed8c7789a2837141746ad653dc209a62918.tar.gz |
test_io.rb: assert_separately
* test/ruby/test_io.rb (test_dup_many, test_set_lineno): use
assert_separately for more descriptive messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 5d554d7fb4..133a1a34a1 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1136,29 +1136,19 @@ class TestIO < Test::Unit::TestCase 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 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" |