mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
test/unit/assertions.rb: return exception
* lib/test/unit/assertions.rb (assert_raise_with_message): return raised exception same as assert_raise. * test/ruby, test/-ext-: use assert_raise_with_message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
289d6bb30f
commit
9ef55da910
17 changed files with 68 additions and 95 deletions
|
@ -248,10 +248,11 @@ class TestModule < Test::Unit::TestCase
|
|||
":",
|
||||
["String::", "[Bug #7573]"],
|
||||
].each do |name, msg|
|
||||
e = assert_raise(NameError, "#{msg}#{': ' if msg}wrong constant name #{name.dump}") {
|
||||
expected = "wrong constant name %s" % name
|
||||
msg = "#{msg}#{': ' if msg}wrong constant name #{name.dump}"
|
||||
assert_raise_with_message(NameError, expected, msg) {
|
||||
Object.const_get name
|
||||
}
|
||||
assert_equal("wrong constant name %s" % name, e.message)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -624,8 +625,9 @@ class TestModule < Test::Unit::TestCase
|
|||
bug5084 = '[ruby-dev:44200]'
|
||||
assert_raise(TypeError, bug5084) { c1.const_get(1) }
|
||||
bug7574 = '[ruby-dev:46749]'
|
||||
e = assert_raise(NameError) { Object.const_get("String\0") }
|
||||
assert_equal("wrong constant name \"String\\u0000\"", e.message, bug7574)
|
||||
assert_raise_with_message(NameError, "wrong constant name \"String\\u0000\"", bug7574) {
|
||||
Object.const_get("String\0")
|
||||
}
|
||||
end
|
||||
|
||||
def test_const_defined_invalid_name
|
||||
|
@ -634,8 +636,9 @@ class TestModule < Test::Unit::TestCase
|
|||
bug5084 = '[ruby-dev:44200]'
|
||||
assert_raise(TypeError, bug5084) { c1.const_defined?(1) }
|
||||
bug7574 = '[ruby-dev:46749]'
|
||||
e = assert_raise(NameError) { Object.const_defined?("String\0") }
|
||||
assert_equal("wrong constant name \"String\\u0000\"", e.message, bug7574)
|
||||
assert_raise_with_message(NameError, "wrong constant name \"String\\u0000\"", bug7574) {
|
||||
Object.const_defined?("String\0")
|
||||
}
|
||||
end
|
||||
|
||||
def test_const_get_no_inherited
|
||||
|
@ -1656,7 +1659,7 @@ class TestModule < Test::Unit::TestCase
|
|||
@@foo
|
||||
$foo
|
||||
].each do |name|
|
||||
assert_raise(NameError) do
|
||||
assert_raise_with_message(NameError, /#{Regexp.quote(name)}/) do
|
||||
Module.new { attr_accessor name.to_sym }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue