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:
parent
ecec550855
commit
5f4778d347
3 changed files with 23 additions and 12 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue