mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
7d95b96e7b
commit
55e68f0e78
1 changed files with 15 additions and 27 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue