eventmachine 1.0.0.beta.2-x86-mswin32-60 → 1.0.0.beta.3-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.yardopts +3 -0
  2. data/Gemfile +1 -0
  3. data/eventmachine.gemspec +1 -3
  4. data/ext/cmain.cpp +4 -4
  5. data/ext/ed.cpp +13 -16
  6. data/ext/ed.h +9 -10
  7. data/ext/em.cpp +14 -24
  8. data/ext/eventmachine.h +2 -2
  9. data/ext/extconf.rb +1 -1
  10. data/ext/rubymain.cpp +8 -6
  11. data/lib/em/connection.rb +3 -1
  12. data/lib/em/pure_ruby.rb +17 -17
  13. data/lib/em/resolver.rb +186 -0
  14. data/lib/em/spawnable.rb +3 -7
  15. data/lib/em/version.rb +1 -1
  16. data/lib/eventmachine.rb +6 -4
  17. data/lib/jeventmachine.rb +1 -1
  18. data/tasks/package.rake +4 -1
  19. data/tasks/test.rake +1 -0
  20. data/tests/em_test_helper.rb +55 -0
  21. data/tests/test_attach.rb +46 -56
  22. data/tests/test_basic.rb +74 -96
  23. data/tests/test_channel.rb +2 -4
  24. data/tests/test_connection_count.rb +1 -3
  25. data/tests/test_defer.rb +13 -44
  26. data/tests/test_deferrable.rb +19 -19
  27. data/tests/test_epoll.rb +25 -55
  28. data/tests/test_error_handler.rb +10 -7
  29. data/tests/test_exc.rb +6 -33
  30. data/tests/test_file_watch.rb +51 -35
  31. data/tests/test_futures.rb +9 -37
  32. data/tests/test_get_sock_opt.rb +27 -20
  33. data/tests/test_handler_check.rb +1 -3
  34. data/tests/test_hc.rb +24 -59
  35. data/tests/test_httpclient.rb +27 -64
  36. data/tests/test_httpclient2.rb +1 -29
  37. data/tests/test_inactivity_timeout.rb +44 -40
  38. data/tests/test_kb.rb +26 -52
  39. data/tests/test_ltp.rb +23 -67
  40. data/tests/test_ltp2.rb +1 -30
  41. data/tests/test_next_tick.rb +1 -30
  42. data/tests/test_object_protocol.rb +8 -9
  43. data/tests/test_pause.rb +45 -37
  44. data/tests/test_pending_connect_timeout.rb +42 -38
  45. data/tests/test_process_watch.rb +1 -3
  46. data/tests/test_processes.rb +92 -110
  47. data/tests/test_proxy_connection.rb +128 -104
  48. data/tests/test_pure.rb +29 -75
  49. data/tests/test_queue.rb +2 -4
  50. data/tests/test_resolver.rb +55 -0
  51. data/tests/test_running.rb +1 -29
  52. data/tests/test_sasl.rb +7 -32
  53. data/tests/test_send_file.rb +162 -196
  54. data/tests/test_servers.rb +13 -56
  55. data/tests/test_smtpclient.rb +1 -29
  56. data/tests/test_smtpserver.rb +1 -29
  57. data/tests/test_spawn.rb +2 -31
  58. data/tests/test_ssl_args.rb +9 -10
  59. data/tests/test_ssl_methods.rb +1 -3
  60. data/tests/test_ssl_verify.rb +63 -63
  61. data/tests/test_tick_loop.rb +1 -1
  62. data/tests/test_timers.rb +52 -89
  63. data/tests/test_ud.rb +1 -29
  64. metadata +20 -10
  65. data/setup.rb +0 -1585
  66. data/tests/test_errors.rb +0 -82
  67. data/tests/testem.rb +0 -31
@@ -1,76 +1,33 @@
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
- $:.unshift "../lib"
28
- require 'eventmachine'
1
+ require 'em_test_helper'
29
2
  require 'socket'
30
- require 'test/unit'
31
3
 
32
4
  class TestServers < Test::Unit::TestCase
33
5
 
34
- Host = "127.0.0.1"
35
- Port = 9555
36
-
37
- module NetstatHelper
38
- GlobalUdp4Rexp = /udp.*\s+(?:\*|(?:0\.){3}0)[:.](\d+)\s/i
39
- GlobalTcp4Rexp = /tcp.*\s+(?:\*|(?:0\.){3}0)[:.](\d+)\s/i
40
- LocalUdpRexp = /udp.*\s+(?:127\.0\.0\.1|::1)[:.](\d+)\s/i
41
- LocalTcpRexp = /tcp.*\s+(?:127\.0\.0\.1|::1)[:.](\d+)\s/i
42
- def grep_netstat(pattern)
43
- `netstat -an`.scan(/^.*$/).grep(pattern)
44
- end
6
+ def setup
7
+ @port = next_port
45
8
  end
46
- include NetstatHelper
47
9
 
48
- class TestStopServer < EM::Connection
49
- def initialize *args
50
- super
51
- end
52
- def post_init
53
- # TODO,sucks that this isn't OOPy enough.
54
- EM.stop_server @server_instance
55
- end
10
+ def server_alive?
11
+ port_in_use?(@port)
56
12
  end
57
13
 
58
14
  def run_test_stop_server
59
15
  EM.run {
60
- sig = EM.start_server(Host, Port)
61
- assert(grep_netstat(LocalTcpRexp).grep(%r(#{Port})).size >= 1, "Server didn't start")
16
+ sig = EM.start_server("127.0.0.1", @port)
17
+ assert server_alive?, "Server didn't start"
62
18
  EM.stop_server sig
63
19
  # Give the server some time to shutdown.
64
- EM.add_timer(0.2) {
65
- assert(grep_netstat(LocalTcpRexp).grep(%r(#{Port})).empty?, "Servers didn't stop")
20
+ EM.add_timer(0.1) {
21
+ assert !server_alive?, "Server didn't stop"
66
22
  EM.stop
67
23
  }
68
24
  }
69
25
  end
26
+
70
27
  def test_stop_server
71
- assert(grep_netstat(LocalTcpRexp).grep(Port).empty?, "Port already in use")
72
- 5.times {run_test_stop_server}
73
- assert(grep_netstat(LocalTcpRexp).grep(%r(#{Port})).empty?, "Servers didn't stop")
28
+ assert !server_alive?, "Port already in use"
29
+ 2.times { run_test_stop_server }
30
+ assert !server_alive?, "Servers didn't stop"
74
31
  end
75
32
 
76
33
  end
@@ -1,32 +1,4 @@
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
- $:.unshift "../lib"
28
- require 'eventmachine'
29
- require 'test/unit'
1
+ require 'em_test_helper'
30
2
 
31
3
  class TestSmtpClient < Test::Unit::TestCase
32
4
 
@@ -1,32 +1,4 @@
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
- $:.unshift "../lib"
28
- require 'eventmachine'
29
- require 'test/unit'
1
+ require 'em_test_helper'
30
2
 
31
3
  class TestSmtpServer < Test::Unit::TestCase
32
4
 
data/tests/test_spawn.rb CHANGED
@@ -1,34 +1,5 @@
1
- # $Id$
2
- #
3
- # Author:: Francis Cianfrocca (gmail: blackhedd)
4
- # Homepage:: http://rubyeventmachine.com
5
- # Date:: 25 Aug 2007
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
-
29
- $:.unshift "../lib"
30
- require 'eventmachine'
31
- require 'test/unit'
1
+
2
+ require 'em_test_helper'
32
3
 
33
4
 
34
5
 
@@ -1,10 +1,9 @@
1
1
  require "test/unit"
2
2
  require 'tempfile'
3
3
 
4
- $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
- require "eventmachine"
4
+ require 'em_test_helper'
6
5
 
7
- module EventMachine
6
+ module EM
8
7
  def self._set_mocks
9
8
  class <<self
10
9
  alias set_tls_parms_old set_tls_parms
@@ -36,11 +35,11 @@ end
36
35
 
37
36
  class TestSslArgs < Test::Unit::TestCase
38
37
  def setup
39
- EventMachine._set_mocks
38
+ EM._set_mocks
40
39
  end
41
40
 
42
41
  def teardown
43
- EventMachine._clear_mocks
42
+ EM._clear_mocks
44
43
  end
45
44
 
46
45
  def test_tls_params_file_doesnt_exist
@@ -50,15 +49,15 @@ class TestSslArgs < Test::Unit::TestCase
50
49
  end
51
50
 
52
51
  # associate_callback_target is a pain! (build!)
53
- conn = EventMachine::Connection.new('foo')
52
+ conn = EM::Connection.new('foo')
54
53
 
55
- assert_raises(EventMachine::FileNotFoundException) do
54
+ assert_raises(EM::FileNotFoundException) do
56
55
  conn.start_tls(:private_key_file => priv_file)
57
56
  end
58
- assert_raises(EventMachine::FileNotFoundException) do
57
+ assert_raises(EM::FileNotFoundException) do
59
58
  conn.start_tls(:cert_chain_file => cert_file)
60
59
  end
61
- assert_raises(EventMachine::FileNotFoundException) do
60
+ assert_raises(EM::FileNotFoundException) do
62
61
  conn.start_tls(:private_key_file => priv_file, :cert_chain_file => cert_file)
63
62
  end
64
63
  end
@@ -68,7 +67,7 @@ class TestSslArgs < Test::Unit::TestCase
68
67
  cert_file = Tempfile.new('em_test')
69
68
  priv_file_path = priv_file.path
70
69
  cert_file_path = cert_file.path
71
- conn = EventMachine::Connection.new('foo')
70
+ conn = EM::Connection.new('foo')
72
71
  params = {:private_key_file => priv_file_path, :cert_chain_file => cert_file_path}
73
72
  begin
74
73
  conn.start_tls params
@@ -1,6 +1,4 @@
1
- $:.unshift "../lib"
2
- require 'eventmachine'
3
- require 'test/unit'
1
+ require 'em_test_helper'
4
2
 
5
3
  class TestSSLMethods < Test::Unit::TestCase
6
4
 
@@ -1,82 +1,82 @@
1
- $:.unshift "../lib"
2
- require 'eventmachine'
3
- require 'test/unit'
1
+ require 'em_test_helper'
4
2
 
5
- class TestSslVerify < Test::Unit::TestCase
6
-
7
- def setup
8
- $dir = File.dirname(File.expand_path(__FILE__)) + '/'
9
- $cert_from_file = File.read($dir+'client.crt')
10
- end
11
-
12
- module Client
13
- def connection_completed
14
- start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt')
3
+ if EM.ssl?
4
+ class TestSslVerify < Test::Unit::TestCase
5
+ def setup
6
+ $dir = File.dirname(File.expand_path(__FILE__)) + '/'
7
+ $cert_from_file = File.read($dir+'client.crt')
15
8
  end
16
9
 
17
- def ssl_handshake_completed
18
- $client_handshake_completed = true
19
- close_connection
20
- end
10
+ module Client
11
+ def connection_completed
12
+ start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt')
13
+ end
21
14
 
22
- def unbind
23
- EM.stop_event_loop
24
- end
25
- end
15
+ def ssl_handshake_completed
16
+ $client_handshake_completed = true
17
+ close_connection
18
+ end
26
19
 
27
- module AcceptServer
28
- def post_init
29
- start_tls(:verify_peer => true)
20
+ def unbind
21
+ EM.stop_event_loop
22
+ end
30
23
  end
31
24
 
32
- def ssl_verify_peer(cert)
33
- $cert_from_server = cert
34
- true
35
- end
25
+ module AcceptServer
26
+ def post_init
27
+ start_tls(:verify_peer => true)
28
+ end
36
29
 
37
- def ssl_handshake_completed
38
- $server_handshake_completed = true
39
- end
40
- end
30
+ def ssl_verify_peer(cert)
31
+ $cert_from_server = cert
32
+ true
33
+ end
41
34
 
42
- module DenyServer
43
- def post_init
44
- start_tls(:verify_peer => true)
35
+ def ssl_handshake_completed
36
+ $server_handshake_completed = true
37
+ end
45
38
  end
46
39
 
47
- def ssl_verify_peer(cert)
48
- $cert_from_server = cert
49
- # Do not accept the peer. This should now cause the connection to shut down without the SSL handshake being completed.
50
- false
51
- end
40
+ module DenyServer
41
+ def post_init
42
+ start_tls(:verify_peer => true)
43
+ end
52
44
 
53
- def ssl_handshake_completed
54
- $server_handshake_completed = true
45
+ def ssl_verify_peer(cert)
46
+ $cert_from_server = cert
47
+ # Do not accept the peer. This should now cause the connection to shut down without the SSL handshake being completed.
48
+ false
49
+ end
50
+
51
+ def ssl_handshake_completed
52
+ $server_handshake_completed = true
53
+ end
55
54
  end
56
- end
57
55
 
58
- def test_accept_server
59
- $client_handshake_completed, $server_handshake_completed = false, false
60
- EM.run {
61
- EM.start_server("127.0.0.1", 16784, AcceptServer)
62
- EM.connect("127.0.0.1", 16784, Client).instance_variable_get("@signature")
63
- }
56
+ def test_accept_server
57
+ $client_handshake_completed, $server_handshake_completed = false, false
58
+ EM.run {
59
+ EM.start_server("127.0.0.1", 16784, AcceptServer)
60
+ EM.connect("127.0.0.1", 16784, Client).instance_variable_get("@signature")
61
+ }
64
62
 
65
- assert_equal($cert_from_file, $cert_from_server)
66
- assert($client_handshake_completed)
67
- assert($server_handshake_completed)
68
- end
63
+ assert_equal($cert_from_file, $cert_from_server)
64
+ assert($client_handshake_completed)
65
+ assert($server_handshake_completed)
66
+ end
69
67
 
70
- def test_deny_server
71
- $client_handshake_completed, $server_handshake_completed = false, false
72
- EM.run {
73
- EM.start_server("127.0.0.1", 16784, DenyServer)
74
- EM.connect("127.0.0.1", 16784, Client)
75
- }
68
+ def test_deny_server
69
+ $client_handshake_completed, $server_handshake_completed = false, false
70
+ EM.run {
71
+ EM.start_server("127.0.0.1", 16784, DenyServer)
72
+ EM.connect("127.0.0.1", 16784, Client)
73
+ }
76
74
 
77
- assert_equal($cert_from_file, $cert_from_server)
78
- assert(!$client_handshake_completed)
79
- assert(!$server_handshake_completed)
75
+ assert_equal($cert_from_file, $cert_from_server)
76
+ assert(!$client_handshake_completed)
77
+ assert(!$server_handshake_completed)
78
+ end
80
79
  end
81
-
80
+ else
81
+ warn "EM built without SSL support, skipping tests in #{__FILE__}"
82
82
  end
@@ -1,5 +1,5 @@
1
1
  require "test/unit"
2
- require "eventmachine"
2
+ require 'em_test_helper'
3
3
 
4
4
  class TestEmTickLoop < Test::Unit::TestCase
5
5
  def test_em_tick_loop
data/tests/test_timers.rb CHANGED
@@ -1,42 +1,13 @@
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
- $:.unshift "../lib"
29
- require 'eventmachine'
30
- require 'test/unit'
1
+ require 'em_test_helper'
31
2
 
32
3
  class TestTimers < Test::Unit::TestCase
33
4
 
34
5
  def test_timer_with_block
35
6
  x = false
36
- EventMachine.run {
37
- EventMachine::Timer.new(0.25) {
7
+ EM.run {
8
+ EM::Timer.new(0) {
38
9
  x = true
39
- EventMachine.stop
10
+ EM.stop
40
11
  }
41
12
  }
42
13
  assert x
@@ -44,117 +15,109 @@ class TestTimers < Test::Unit::TestCase
44
15
 
45
16
  def test_timer_with_proc
46
17
  x = false
47
- EventMachine.run {
48
- EventMachine::Timer.new(0.25, proc {
18
+ EM.run {
19
+ EM::Timer.new(0, proc {
49
20
  x = true
50
- EventMachine.stop
21
+ EM.stop
51
22
  })
52
23
  }
53
24
  assert x
54
25
  end
55
26
 
56
27
  def test_timer_cancel
57
- x = true
58
- EventMachine.run {
59
- timer = EventMachine::Timer.new(0.25, proc { x = false })
60
- timer.cancel
61
- EventMachine::Timer.new(0.5, proc {EventMachine.stop})
62
- }
63
- assert x
28
+ assert_nothing_raised do
29
+ EM.run {
30
+ timer = EM::Timer.new(0.01) { flunk "Timer was not cancelled." }
31
+ timer.cancel
32
+
33
+ EM.add_timer(0.02) { EM.stop }
34
+ }
35
+ end
64
36
  end
65
37
 
66
38
  def test_periodic_timer
67
39
  x = 0
68
- EventMachine.run {
69
- EventMachine::PeriodicTimer.new(0.1) do
40
+ EM.run {
41
+ EM::PeriodicTimer.new(0.01) do
70
42
  x += 1
71
- EventMachine.stop if x == 4
43
+ EM.stop if x == 4
72
44
  end
73
45
  }
74
- assert( x == 4 )
46
+
47
+ assert_equal 4, x
75
48
  end
76
49
 
77
50
  def test_add_periodic_timer
78
51
  x = 0
79
52
  EM.run {
80
- t = EM.add_periodic_timer(0.1) do
53
+ t = EM.add_periodic_timer(0.01) do
81
54
  x += 1
82
55
  EM.stop if x == 4
83
56
  end
84
57
  assert t.respond_to?(:cancel)
85
58
  }
59
+ assert_equal 4, x
86
60
  end
87
61
 
88
62
  def test_periodic_timer_cancel
89
63
  x = 0
90
- EventMachine.run {
91
- pt = EventMachine::PeriodicTimer.new(0.25, proc { x += 1 })
64
+ EM.run {
65
+ pt = EM::PeriodicTimer.new(0.01) { x += 1 }
92
66
  pt.cancel
93
- EventMachine::Timer.new(0.5) {EventMachine.stop}
67
+ EM::Timer.new(0.02) { EM.stop }
94
68
  }
95
- assert( x == 0 )
69
+ assert_equal 0, x
96
70
  end
97
71
 
98
72
  def test_add_periodic_timer_cancel
99
73
  x = 0
100
- EventMachine.run {
101
- pt = EM.add_periodic_timer(0.1) { x += 1 }
74
+ EM.run {
75
+ pt = EM.add_periodic_timer(0.01) { x += 1 }
102
76
  EM.cancel_timer(pt)
103
- EM.add_timer(0.2) { EM.stop }
77
+ EM.add_timer(0.02) { EM.stop }
104
78
  }
105
- assert( x == 0 )
79
+ assert_equal 0, x
106
80
  end
107
81
 
108
82
  def test_periodic_timer_self_cancel
109
83
  x = 0
110
- EventMachine.run {
111
- pt = EventMachine::PeriodicTimer.new(0.1) {
84
+ EM.run {
85
+ pt = EM::PeriodicTimer.new(0) {
112
86
  x += 1
113
87
  if x == 4
114
88
  pt.cancel
115
- EventMachine.stop
89
+ EM.stop
116
90
  end
117
91
  }
118
92
  }
119
- assert( x == 4 )
93
+ assert_equal 4, x
120
94
  end
121
95
 
122
96
 
123
97
  # This test is only applicable to compiled versions of the reactor.
124
98
  # Pure ruby and java versions have no built-in limit on the number of outstanding timers.
125
- #
126
- def test_timer_change_max_outstanding
127
- defaults = EM.get_max_timers
128
- EM.set_max_timers(100)
129
-
130
- one_hundred_one_timers = proc { 101.times { EM.add_timer(5) {} } }
99
+ unless [:pure_ruby, :java].include? EM.library_type
100
+ def test_timer_change_max_outstanding
101
+ defaults = EM.get_max_timers
102
+ EM.set_max_timers(100)
103
+
104
+ one_hundred_one_timers = lambda do
105
+ 101.times { EM.add_timer(0.01) {} }
106
+ EM.stop
107
+ end
131
108
 
132
- EM.run {
133
- if EM.library_type == :pure_ruby
134
- one_hundred_one_timers.call
135
- elsif EM.library_type == :java
136
- one_hundred_one_timers.call
137
- else
138
- begin
139
- assert_raises( RuntimeError ) {
140
- one_hundred_one_timers.call
141
- }
142
- rescue Object
143
- p $!
144
- assert(false, $!.message)
145
- end
109
+ assert_raises(RuntimeError) do
110
+ EM.run( &one_hundred_one_timers )
146
111
  end
147
- EM.stop
148
- }
149
112
 
150
- EM.set_max_timers( 101 )
113
+ EM.set_max_timers( 101 )
151
114
 
152
- EM.run {
153
- one_hundred_one_timers.call
154
- EM.stop
155
- }
156
- ensure
157
- EM.set_max_timers(defaults)
115
+ assert_nothing_raised do
116
+ EM.run( &one_hundred_one_timers )
117
+ end
118
+ ensure
119
+ EM.set_max_timers(defaults)
120
+ end
158
121
  end
159
122
 
160
123
  end