summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 02:20:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 02:20:34 +0000
commit18d47904a44b711391116edda7659ce02e22f38f (patch)
treed33b373677ff60368654ad55107e3db5cd4ca789
parent77cde58d394b01c7b5f1ab5078d18e04373065db (diff)
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
-rw-r--r--test/webrick/test_utils.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/webrick/test_utils.rb b/test/webrick/test_utils.rb
index 9f62c81..3ab4f2b 100644
--- a/test/webrick/test_utils.rb
+++ b/test/webrick/test_utils.rb
@@ -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)