mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
timeout.rb: defer creating custom exception
* lib/timeout.rb (Timeout#timeout): when a custom exception is given, no instance is needed to be caught, so defer creating new instance until it is raised. [ruby-core:59511] [Bug #9354] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
765ec40120
commit
9f5537c5b3
3 changed files with 19 additions and 2 deletions
|
|
@ -57,4 +57,14 @@ class TestTimeout < Test::Unit::TestCase
|
|||
end
|
||||
assert_raise_with_message(exc, /execution expired/) {raise e if e}
|
||||
end
|
||||
|
||||
def test_custom_exception
|
||||
bug9354 = '[ruby-core:59511] [Bug #9354]'
|
||||
err = Class.new(StandardError) do
|
||||
def initialize(msg) super end
|
||||
end
|
||||
assert_nothing_raised(ArgumentError, bug9354) do
|
||||
assert_equal(:ok, timeout(100, err) {:ok})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue