1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2003-11-12 08:32:54 +00:00
parent ecec550855
commit 5f4778d347
3 changed files with 23 additions and 12 deletions

View file

@ -1,3 +1,11 @@
Wed Nov 12 17:32:49 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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.
Wed Nov 12 14:09:43 2003 Shugo Maeda <shugo@ruby-lang.org>
* test/monitor/test_monitor.rb: fix the timing problem by Queue.

View file

@ -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,9 +252,9 @@ 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)
@ -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)

View file

@ -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:')