[前][次][番号順一覧][スレッド一覧]

ruby-changes:39151

From: nobu <ko1@a...>
Date: Tue, 14 Jul 2015 11:20:54 +0900 (JST)
Subject: [ruby-changes:39151] nobu:r51232 (trunk): test_utils.rb: split

nobu	2015-07-14 11:20:34 +0900 (Tue, 14 Jul 2015)

  New Revision: 51232

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51232

  Log:
    test_utils.rb: split
    
    * test/webrick/test_utils.rb (TestWEBrickUtils#do_tet_timeout):
      split into tests.

  Modified files:
    trunk/test/webrick/test_utils.rb
Index: test/webrick/test_utils.rb
===================================================================
--- test/webrick/test_utils.rb	(revision 51231)
+++ test/webrick/test_utils.rb	(revision 51232)
@@ -9,12 +9,16 @@ class TestWEBrickUtils < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/webrick/test_utils.rb#L9
     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::Tes https://github.com/ruby/ruby/blob/trunk/test/webrick/test_utils.rb#L30
     }
     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::Tes https://github.com/ruby/ruby/blob/trunk/test/webrick/test_utils.rb#L57
     }
     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::Tes https://github.com/ruby/ruby/blob/trunk/test/webrick/test_utils.rb#L73
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]