mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err): new
method. * test/ruby/test_argf.rb: use assert_in_out_err instead of EnvUtil.rubyexec. * test/ruby/test_module.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_objectspace.rb: ditto. * test/ruby/test_object.rb: ditto. * test/ruby/test_string.rb: ditto. * test/ruby/test_method.rb: ditto. * test/ruby/test_variable.rb: ditto. * test/ruby/test_io.rb: ditto. * test/ruby/test_rubyoptions.rb: ditto. * test/ruby/test_exception.rb: ditto. * test/ruby/test_class.rb: ditto. * test/ruby/test_thread.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e74af2cf41
commit
eafe85f603
15 changed files with 568 additions and 869 deletions
|
@ -2,10 +2,6 @@ require 'test/unit'
|
|||
require_relative 'envutil'
|
||||
|
||||
class TestException < Test::Unit::TestCase
|
||||
def ruby(*r, &b)
|
||||
EnvUtil.rubyexec(*r, &b)
|
||||
end
|
||||
|
||||
def test_exception
|
||||
begin
|
||||
raise "this must be handled"
|
||||
|
@ -197,53 +193,34 @@ class TestException < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_errat
|
||||
ruby do |w, r, e|
|
||||
w.puts "p $@"
|
||||
w.close
|
||||
assert_equal("nil", r.read.chomp)
|
||||
assert_equal("", e.read.chomp)
|
||||
end
|
||||
assert_in_out_err([], "p $@", %w(nil), [])
|
||||
|
||||
ruby do |w, r, e|
|
||||
w.puts "$@ = 1"
|
||||
w.close
|
||||
assert_equal("", r.read.chomp)
|
||||
assert_match(/\$! not set \(ArgumentError\)$/, e.read.chomp)
|
||||
end
|
||||
assert_in_out_err([], "$@ = 1", [], /\$! not set \(ArgumentError\)$/)
|
||||
|
||||
ruby do |w, r, e|
|
||||
w.puts "begin"
|
||||
w.puts " raise"
|
||||
w.puts "rescue"
|
||||
w.puts " $@ = 1"
|
||||
w.puts "end"
|
||||
w.close
|
||||
assert_equal("", r.read.chomp)
|
||||
assert_match(/backtrace must be Array of String \(TypeError\)$/, e.read.chomp)
|
||||
end
|
||||
assert_in_out_err([], <<-INPUT, [], /backtrace must be Array of String \(TypeError\)$/)
|
||||
begin
|
||||
raise
|
||||
rescue
|
||||
$@ = 1
|
||||
end
|
||||
INPUT
|
||||
|
||||
ruby do |w, r, e|
|
||||
w.puts "begin"
|
||||
w.puts " raise"
|
||||
w.puts "rescue"
|
||||
w.puts " $@ = 'foo'"
|
||||
w.puts " raise"
|
||||
w.puts "end"
|
||||
w.close
|
||||
assert_equal("", r.read.chomp)
|
||||
assert_match(/^foo: unhandled exception$/, e.read.chomp)
|
||||
end
|
||||
assert_in_out_err([], <<-INPUT, [], /^foo: unhandled exception$/)
|
||||
begin
|
||||
raise
|
||||
rescue
|
||||
$@ = 'foo'
|
||||
raise
|
||||
end
|
||||
INPUT
|
||||
|
||||
ruby do |w, r, e|
|
||||
w.puts "begin"
|
||||
w.puts " raise"
|
||||
w.puts "rescue"
|
||||
w.puts " $@ = %w(foo bar baz)"
|
||||
w.puts " raise"
|
||||
w.puts "end"
|
||||
w.close
|
||||
assert_equal("", r.read.chomp)
|
||||
assert_match(/^foo: unhandled exception\s+from bar\s+from baz$/, e.read.chomp)
|
||||
end
|
||||
assert_in_out_err([], <<-INPUT, [], /^foo: unhandled exception\s+from bar\s+from baz$/)
|
||||
begin
|
||||
raise
|
||||
rescue
|
||||
$@ = %w(foo bar baz)
|
||||
raise
|
||||
end
|
||||
INPUT
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue