diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-09 08:43:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-09 08:43:12 +0000 |
commit | 9ef55da91006a19dc4fb612c735b335175b3259b (patch) | |
tree | d1b5676b11b6cf64709f040c2c1b4aba60da02fe /test/ruby/test_module.rb | |
parent | 289d6bb30f4c2fffa2437436030c889f10522e72 (diff) | |
download | ruby-9ef55da91006a19dc4fb612c735b335175b3259b.tar.gz |
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
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r-- | test/ruby/test_module.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index ddaf6777b4..9ad2f39fa9 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -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 |