root/trunk/tests/test_errors.rb

Revision 668, 1.8 kB (checked in by blackhedd, 1 year ago)

migrated version_0 to trunk

  • Property svn:keywords set to Id
Line 
1 # $Id$
2 #
3 # Author:: Francis Cianfrocca (gmail: blackhedd)
4 # Homepage::  http://rubyeventmachine.com
5 # Date:: 8 April 2006
6 #
7 # See EventMachine and EventMachine::Connection for documentation and
8 # usage examples.
9 #
10 #----------------------------------------------------------------------------
11 #
12 # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13 # Gmail: blackhedd
14 #
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of either: 1) the GNU General Public License
17 # as published by the Free Software Foundation; either version 2 of the
18 # License, or (at your option) any later version; or 2) Ruby's License.
19 #
20 # See the file COPYING for complete licensing information.
21 #
22 #---------------------------------------------------------------------------
23 #
24 #
25 #
26
27
28 ###### THIS TEST IS NOW OBSOLETE.
29 ###### As of 27Dec07, the hookable error handling is obsolete because
30 ###### of its performance impact.
31
32
33 $:.unshift "../lib"
34 require 'eventmachine'
35 require 'test/unit'
36
37 class TestErrors < Test::Unit::TestCase
38
39         Localhost = "127.0.0.1"
40         Localport = 9801
41
42         def setup
43         end
44
45         def teardown
46                 # Calling #set_runtime_error_hook with no block restores the
47                 # default handling of runtime_errors.
48                 #
49                 EM.set_runtime_error_hook
50         end
51
52         def test_a
53         end
54
55         # EM has a default handler for RuntimeErrors that are emitted from
56         # user written code. You can override the handler if you wish, but it's
57         # easier to call #set_runtime_error_hook.
58         # Ordinarily, an error in user code invoked by the reactor aborts the
59         # run.
60         #
61         def obsolete_test_unhandled_error
62                 assert_raise( RuntimeError ) {
63                         EM.run {
64                                 EM.add_timer(0) {raise "AAA"}
65                         }
66                 }
67
68         end
69
70         def obsolete_test_handled_error
71                 err = nil
72                 EM.run {
73                         EM.set_runtime_error_hook {
74                                 err = true
75                                 EM.stop
76                         }
77                         EM.add_timer(0) {raise "AAA"}
78                 }
79                 assert err
80         end
81 end
82
Note: See TracBrowser for help on using the browser.