diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-24 05:08:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-24 05:08:04 +0000 |
commit | 73d77c8f572b760b4c868579188fc39f360151cb (patch) | |
tree | 3b5013c7ceed366ab596efd596feb3831f5fc02f /test | |
parent | d05b3b1e4801903a3f6338af932be334049de1ed (diff) |
* lib/test/unit/assertions.rb: Modules are allowed to rescue.
* lib/test/unit/autorunner.rb: show output_level in order.
* lib/test/unit/collector/dir.rb: get rid of successive same
directories in load path.
* test/testunit/test_assertions.rb (test_assert_nothing_raised,
test_assert_raise): test for modules.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/drb/test_drb.rb | 1 | ||||
-rw-r--r-- | test/testunit/test_assertions.rb | 19 |
2 files changed, 15 insertions, 5 deletions
diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb index 753ff09335..5a4a98e1cc 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -1,4 +1,3 @@ -$:.unshift(File.dirname(File.expand_path(__FILE__))) require 'drbtest' class TestDRbCore < Test::Unit::TestCase diff --git a/test/testunit/test_assertions.rb b/test/testunit/test_assertions.rb index 999376e765..8ccd2a81bd 100644 --- a/test/testunit/test_assertions.rb +++ b/test/testunit/test_assertions.rb @@ -145,17 +145,28 @@ module Test } exceptions = [ArgumentError, TypeError] + modules = [Math, Comparable] + rescues = exceptions + modules exceptions.each do |exc| check_nothing_fails(true) { - return_value = assert_raise(*exceptions) { + return_value = assert_raise(*rescues) { raise exc, "Error" } } check(return_value.instance_of?(exc), "Should have returned #{exc} but was #{return_value.class}") check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise") end - check_fails("<[ArgumentError, TypeError]> exception expected but none was thrown.") { - assert_raise(*exceptions) { + modules.each do |mod| + check_nothing_fails(true) { + return_value = assert_raise(*rescues) { + raise Exception.new("Error").extend(mod) + } + } + check(mod === return_value, "Should have returned #{mod}") + check(return_value.message == "Error", "Should have returned the correct exception from a successful assert_raise") + end + check_fails("<[ArgumentError, TypeError, Math, Comparable]> exception expected but none was thrown.") { + assert_raise(*rescues) { 1 + 1 } } @@ -298,7 +309,7 @@ Message: <"Error"> } check_nothing_fails { begin - assert_nothing_raised(RuntimeError, StandardError, "successful assert_nothing_raised") { + assert_nothing_raised(RuntimeError, StandardError, Comparable, "successful assert_nothing_raised") { raise ZeroDivisionError.new("ArgumentError") } rescue ZeroDivisionError |