diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-12 08:32:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-12 08:32:54 +0000 |
commit | 5f4778d3479f4af21000dd194485519e41835d29 (patch) | |
tree | f0681f5d371255a2ebaac9853283fc5a835096fa /lib/test/unit | |
parent | ecec55085597dd393a340664f93e61e9a8876044 (diff) | |
download | ruby-5f4778d3479f4af21000dd194485519e41835d29.tar.gz |
* lib/test/unit/assertions.rb (assert_throws, assert_nothing_thrown):
uncaught throw in sub thread raises ThreadError.
* lib/test/unit/ui/tk/testrunner.rb (setup_ui): "expand" is not
necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test/unit')
-rw-r--r-- | lib/test/unit/assertions.rb | 17 | ||||
-rw-r--r-- | lib/test/unit/ui/tk/testrunner.rb | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb index c9ee8c101a..42f7379526 100644 --- a/lib/test/unit/assertions.rb +++ b/lib/test/unit/assertions.rb @@ -235,6 +235,9 @@ EOT end end + UncaughtThrow = {NameError => /^uncaught throw \`(.+)\'$/, + ThreadError => /^uncaught throw \`(.+)\' in thread /} + # Passes if block throws symbol. public def assert_throws(expected_symbol, message="", &proc) @@ -249,13 +252,13 @@ EOT end full_message = build_message(message, "<?> should have been thrown.", expected_symbol) assert_block(full_message){caught} - rescue NameError => name_error - if ( name_error.message !~ /^uncaught throw `(.+)'$/ ) #` - raise name_error + rescue NameError, ThreadError => error + if UncaughtThrow[error.class] !~ error.message + raise error end full_message = build_message(message, "<?> expected to be thrown but\n<?> was thrown.", expected_symbol, $1.intern) flunk(full_message) - end + end end end @@ -266,9 +269,9 @@ EOT assert(block_given?, "Should have passed a block to assert_nothing_thrown") begin proc.call - rescue NameError => name_error - if (name_error.message !~ /^uncaught throw `(.+)'$/ ) #` - raise name_error + rescue NameError, ThreadError => error + if UncaughtThrow[error.class] !~ error.message + raise error end full_message = build_message(message, "<?> was thrown when nothing was expected", $1.intern) flunk(full_message) diff --git a/lib/test/unit/ui/tk/testrunner.rb b/lib/test/unit/ui/tk/testrunner.rb index adf5a10222..b37b79fd80 100644 --- a/lib/test/unit/ui/tk/testrunner.rb +++ b/lib/test/unit/ui/tk/testrunner.rb @@ -172,7 +172,7 @@ module Test f = TkFrame.new(nil, 'relief'=>'sunken', 'borderwidth'=>3, 'height'=>20).pack('fill'=>'x', 'padx'=>1) @test_progress_bar = TkFrame.new(f, 'background'=>'green').place('anchor'=>'nw', 'relwidth'=>0.0, 'relheight'=>1.0) - info_frame = TkFrame.new.pack('fill'=>'x', 'expand'=>true) + info_frame = TkFrame.new.pack('fill'=>'x') @test_count_label = create_count_label(info_frame, 'Tests:') @assertion_count_label = create_count_label(info_frame, 'Assertions:') @failure_count_label = create_count_label(info_frame, 'Failures:') |