mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_utils.rb: split
* test/webrick/test_utils.rb (TestWEBrickUtils#do_tet_timeout): split into tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
77cde58d39
commit
18d47904a4
1 changed files with 21 additions and 6 deletions
|
@ -9,12 +9,16 @@ class TestWEBrickUtils < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def do_test_timeout(m)
|
||||
ex = Class.new(StandardError)
|
||||
EX = Class.new(StandardError)
|
||||
|
||||
def test_no_timeout
|
||||
m = WEBrick::Utils
|
||||
assert_equal(:foo, m.timeout(10){ :foo })
|
||||
assert_expired(true, m)
|
||||
end
|
||||
|
||||
def test_nested_timeout_outer
|
||||
m = WEBrick::Utils
|
||||
i = 0
|
||||
assert_raise(Timeout::Error){
|
||||
m.timeout(2){
|
||||
|
@ -26,13 +30,24 @@ class TestWEBrickUtils < Test::Unit::TestCase
|
|||
}
|
||||
assert_equal(2, i)
|
||||
assert_expired(true, m)
|
||||
end
|
||||
|
||||
def test_timeout_default_execption
|
||||
m = WEBrick::Utils
|
||||
assert_raise(Timeout::Error){ m.timeout(0.1){ sleep } }
|
||||
assert_expired(true, m)
|
||||
end
|
||||
|
||||
def test_timeout_custom_exception
|
||||
m = WEBrick::Utils
|
||||
ex = EX
|
||||
assert_raise(ex){ m.timeout(0.1, ex){ sleep } }
|
||||
assert_expired(true, m)
|
||||
end
|
||||
|
||||
def test_nested_timeout_inner_custom_exception
|
||||
m = WEBrick::Utils
|
||||
ex = EX
|
||||
i = 0
|
||||
assert_raise(ex){
|
||||
m.timeout(10){
|
||||
|
@ -42,7 +57,11 @@ class TestWEBrickUtils < Test::Unit::TestCase
|
|||
}
|
||||
assert_equal(1, i)
|
||||
assert_expired(true, m)
|
||||
end
|
||||
|
||||
def test_nested_timeout_outer_custom_exception
|
||||
m = WEBrick::Utils
|
||||
ex = EX
|
||||
i = 0
|
||||
assert_raise(Timeout::Error){
|
||||
m.timeout(1){
|
||||
|
@ -54,10 +73,6 @@ class TestWEBrickUtils < Test::Unit::TestCase
|
|||
assert_expired(true, m)
|
||||
end
|
||||
|
||||
def test_webrick_timeout
|
||||
do_test_timeout(WEBrick::Utils)
|
||||
end
|
||||
|
||||
def test_create_listeners
|
||||
addr = listener_address(0)
|
||||
port = addr.slice!(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue