root/trunk/tests/test_exc.rb

Revision 668, 1.5 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 $:.unshift "../lib"
27 require 'eventmachine'
28 require 'test/unit'
29
30 class TestSomeExceptions < Test::Unit::TestCase
31
32
33     # Read the commentary in EventMachine#run.
34     # This test exercises the ensure block in #run that makes sure
35     # EventMachine#release_machine gets called even if an exception is
36     # thrown within the user code. Without the ensured call to release_machine,
37     # the second call to EventMachine#run will fail with a C++ exception
38     # because the machine wasn't cleaned up properly.
39
40     def test_a
41         assert_raise(RuntimeError) {
42             EventMachine.run {
43                 raise "some exception"
44             }
45         }
46     end
47
48     def test_b
49         assert_raise(RuntimeError) {
50             EventMachine.run {
51                 raise "some exception"
52             }
53         }
54     end
55
56
57 end
58
Note: See TracBrowser for help on using the browser.