eventmachine 1.2.0.dev.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +105 -0
  3. data/GNU +281 -0
  4. data/LICENSE +60 -0
  5. data/README.md +108 -0
  6. data/docs/DocumentationGuidesIndex.md +27 -0
  7. data/docs/GettingStarted.md +521 -0
  8. data/docs/old/ChangeLog +211 -0
  9. data/docs/old/DEFERRABLES +246 -0
  10. data/docs/old/EPOLL +141 -0
  11. data/docs/old/INSTALL +13 -0
  12. data/docs/old/KEYBOARD +42 -0
  13. data/docs/old/LEGAL +25 -0
  14. data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
  15. data/docs/old/PURE_RUBY +75 -0
  16. data/docs/old/RELEASE_NOTES +94 -0
  17. data/docs/old/SMTP +4 -0
  18. data/docs/old/SPAWNED_PROCESSES +148 -0
  19. data/docs/old/TODO +8 -0
  20. data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
  21. data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
  22. data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
  23. data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
  24. data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
  25. data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
  26. data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
  27. data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
  28. data/examples/old/ex_channel.rb +43 -0
  29. data/examples/old/ex_queue.rb +2 -0
  30. data/examples/old/ex_tick_loop_array.rb +15 -0
  31. data/examples/old/ex_tick_loop_counter.rb +32 -0
  32. data/examples/old/helper.rb +2 -0
  33. data/ext/binder.cpp +124 -0
  34. data/ext/binder.h +46 -0
  35. data/ext/cmain.cpp +988 -0
  36. data/ext/ed.cpp +2111 -0
  37. data/ext/ed.h +442 -0
  38. data/ext/em.cpp +2379 -0
  39. data/ext/em.h +308 -0
  40. data/ext/eventmachine.h +143 -0
  41. data/ext/extconf.rb +270 -0
  42. data/ext/fastfilereader/extconf.rb +110 -0
  43. data/ext/fastfilereader/mapper.cpp +216 -0
  44. data/ext/fastfilereader/mapper.h +59 -0
  45. data/ext/fastfilereader/rubymain.cpp +127 -0
  46. data/ext/kb.cpp +79 -0
  47. data/ext/page.cpp +107 -0
  48. data/ext/page.h +51 -0
  49. data/ext/pipe.cpp +354 -0
  50. data/ext/project.h +176 -0
  51. data/ext/rubymain.cpp +1504 -0
  52. data/ext/ssl.cpp +615 -0
  53. data/ext/ssl.h +103 -0
  54. data/java/.classpath +8 -0
  55. data/java/.project +17 -0
  56. data/java/src/com/rubyeventmachine/EmReactor.java +591 -0
  57. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  58. data/java/src/com/rubyeventmachine/EventableChannel.java +72 -0
  59. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +201 -0
  60. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +415 -0
  61. data/lib/2.0/fastfilereaderext.so +0 -0
  62. data/lib/2.0/rubyeventmachine.so +0 -0
  63. data/lib/2.1/fastfilereaderext.so +0 -0
  64. data/lib/2.1/rubyeventmachine.so +0 -0
  65. data/lib/2.2/fastfilereaderext.so +0 -0
  66. data/lib/2.2/rubyeventmachine.so +0 -0
  67. data/lib/2.3/fastfilereaderext.so +0 -0
  68. data/lib/2.3/rubyeventmachine.so +0 -0
  69. data/lib/em/buftok.rb +59 -0
  70. data/lib/em/callback.rb +58 -0
  71. data/lib/em/channel.rb +69 -0
  72. data/lib/em/completion.rb +304 -0
  73. data/lib/em/connection.rb +770 -0
  74. data/lib/em/deferrable.rb +210 -0
  75. data/lib/em/deferrable/pool.rb +2 -0
  76. data/lib/em/file_watch.rb +73 -0
  77. data/lib/em/future.rb +61 -0
  78. data/lib/em/iterator.rb +252 -0
  79. data/lib/em/messages.rb +66 -0
  80. data/lib/em/pool.rb +151 -0
  81. data/lib/em/process_watch.rb +45 -0
  82. data/lib/em/processes.rb +123 -0
  83. data/lib/em/protocols.rb +37 -0
  84. data/lib/em/protocols/header_and_content.rb +138 -0
  85. data/lib/em/protocols/httpclient.rb +299 -0
  86. data/lib/em/protocols/httpclient2.rb +600 -0
  87. data/lib/em/protocols/line_and_text.rb +125 -0
  88. data/lib/em/protocols/line_protocol.rb +29 -0
  89. data/lib/em/protocols/linetext2.rb +166 -0
  90. data/lib/em/protocols/memcache.rb +331 -0
  91. data/lib/em/protocols/object_protocol.rb +46 -0
  92. data/lib/em/protocols/postgres3.rb +246 -0
  93. data/lib/em/protocols/saslauth.rb +175 -0
  94. data/lib/em/protocols/smtpclient.rb +394 -0
  95. data/lib/em/protocols/smtpserver.rb +666 -0
  96. data/lib/em/protocols/socks4.rb +66 -0
  97. data/lib/em/protocols/stomp.rb +205 -0
  98. data/lib/em/protocols/tcptest.rb +54 -0
  99. data/lib/em/pure_ruby.rb +1022 -0
  100. data/lib/em/queue.rb +80 -0
  101. data/lib/em/resolver.rb +232 -0
  102. data/lib/em/spawnable.rb +84 -0
  103. data/lib/em/streamer.rb +118 -0
  104. data/lib/em/threaded_resource.rb +90 -0
  105. data/lib/em/tick_loop.rb +85 -0
  106. data/lib/em/timers.rb +61 -0
  107. data/lib/em/version.rb +3 -0
  108. data/lib/eventmachine.rb +1584 -0
  109. data/lib/fastfilereaderext.rb +2 -0
  110. data/lib/jeventmachine.rb +301 -0
  111. data/lib/rubyeventmachine.rb +2 -0
  112. data/rakelib/package.rake +120 -0
  113. data/rakelib/test.rake +8 -0
  114. data/tests/client.crt +31 -0
  115. data/tests/client.key +51 -0
  116. data/tests/dhparam.pem +13 -0
  117. data/tests/em_test_helper.rb +151 -0
  118. data/tests/test_attach.rb +151 -0
  119. data/tests/test_basic.rb +283 -0
  120. data/tests/test_channel.rb +75 -0
  121. data/tests/test_completion.rb +178 -0
  122. data/tests/test_connection_count.rb +54 -0
  123. data/tests/test_connection_write.rb +35 -0
  124. data/tests/test_defer.rb +35 -0
  125. data/tests/test_deferrable.rb +35 -0
  126. data/tests/test_epoll.rb +142 -0
  127. data/tests/test_error_handler.rb +38 -0
  128. data/tests/test_exc.rb +28 -0
  129. data/tests/test_file_watch.rb +66 -0
  130. data/tests/test_fork.rb +75 -0
  131. data/tests/test_futures.rb +170 -0
  132. data/tests/test_get_sock_opt.rb +37 -0
  133. data/tests/test_handler_check.rb +35 -0
  134. data/tests/test_hc.rb +155 -0
  135. data/tests/test_httpclient.rb +233 -0
  136. data/tests/test_httpclient2.rb +128 -0
  137. data/tests/test_idle_connection.rb +25 -0
  138. data/tests/test_inactivity_timeout.rb +54 -0
  139. data/tests/test_ipv4.rb +125 -0
  140. data/tests/test_ipv6.rb +131 -0
  141. data/tests/test_iterator.rb +115 -0
  142. data/tests/test_kb.rb +28 -0
  143. data/tests/test_line_protocol.rb +33 -0
  144. data/tests/test_ltp.rb +138 -0
  145. data/tests/test_ltp2.rb +308 -0
  146. data/tests/test_many_fds.rb +22 -0
  147. data/tests/test_next_tick.rb +104 -0
  148. data/tests/test_object_protocol.rb +36 -0
  149. data/tests/test_pause.rb +107 -0
  150. data/tests/test_pending_connect_timeout.rb +52 -0
  151. data/tests/test_pool.rb +196 -0
  152. data/tests/test_process_watch.rb +50 -0
  153. data/tests/test_processes.rb +128 -0
  154. data/tests/test_proxy_connection.rb +180 -0
  155. data/tests/test_pure.rb +88 -0
  156. data/tests/test_queue.rb +64 -0
  157. data/tests/test_resolver.rb +104 -0
  158. data/tests/test_running.rb +14 -0
  159. data/tests/test_sasl.rb +47 -0
  160. data/tests/test_send_file.rb +217 -0
  161. data/tests/test_servers.rb +33 -0
  162. data/tests/test_set_sock_opt.rb +39 -0
  163. data/tests/test_shutdown_hooks.rb +23 -0
  164. data/tests/test_smtpclient.rb +75 -0
  165. data/tests/test_smtpserver.rb +57 -0
  166. data/tests/test_spawn.rb +293 -0
  167. data/tests/test_ssl_args.rb +78 -0
  168. data/tests/test_ssl_dhparam.rb +83 -0
  169. data/tests/test_ssl_ecdh_curve.rb +79 -0
  170. data/tests/test_ssl_extensions.rb +49 -0
  171. data/tests/test_ssl_methods.rb +65 -0
  172. data/tests/test_ssl_protocols.rb +246 -0
  173. data/tests/test_ssl_verify.rb +126 -0
  174. data/tests/test_stomp.rb +37 -0
  175. data/tests/test_system.rb +46 -0
  176. data/tests/test_threaded_resource.rb +61 -0
  177. data/tests/test_tick_loop.rb +59 -0
  178. data/tests/test_timers.rb +123 -0
  179. data/tests/test_ud.rb +8 -0
  180. data/tests/test_unbind_reason.rb +52 -0
  181. metadata +381 -0
@@ -0,0 +1,25 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestIdleConnection < Test::Unit::TestCase
4
+ if EM.respond_to?(:get_idle_time)
5
+ def test_idle_time
6
+ EM.run{
7
+ conn = EM.connect 'www.google.com', 80
8
+ EM.add_timer(3){
9
+ $idle_time = conn.get_idle_time
10
+ conn.send_data "GET / HTTP/1.0\r\n\r\n"
11
+ EM.next_tick{
12
+ EM.next_tick{
13
+ $idle_time_after_send = conn.get_idle_time
14
+ conn.close_connection
15
+ EM.stop
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ assert_in_delta 3, $idle_time, 0.2
22
+ assert_in_delta 0, $idle_time_after_send, 0.1
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,54 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestInactivityTimeout < Test::Unit::TestCase
4
+
5
+ if EM.respond_to? :get_comm_inactivity_timeout
6
+ def test_default
7
+ EM.run {
8
+ c = EM.connect("127.0.0.1", 54321)
9
+ assert_equal 0.0, c.comm_inactivity_timeout
10
+ EM.stop
11
+ }
12
+ end
13
+
14
+ def test_set_and_get
15
+ EM.run {
16
+ c = EM.connect("127.0.0.1", 54321)
17
+ c.comm_inactivity_timeout = 2.5
18
+ assert_equal 2.5, c.comm_inactivity_timeout
19
+ EM.stop
20
+ }
21
+ end
22
+
23
+ def test_for_real
24
+ start, finish = nil
25
+
26
+ timeout_handler = Module.new do
27
+ define_method :unbind do
28
+ finish = Time.now
29
+ EM.stop
30
+ end
31
+ end
32
+
33
+ EM.run {
34
+ setup_timeout
35
+ EM.heartbeat_interval = 0.01
36
+ EM.start_server("127.0.0.1", 12345)
37
+ EM.add_timer(0.01) {
38
+ start = Time.now
39
+ c = EM.connect("127.0.0.1", 12345, timeout_handler)
40
+ c.comm_inactivity_timeout = 0.02
41
+ }
42
+ }
43
+
44
+ assert_in_delta(0.02, (finish - start), 0.02)
45
+ end
46
+ else
47
+ warn "EM.comm_inactivity_timeout not implemented, skipping tests in #{__FILE__}"
48
+
49
+ # Because some rubies will complain if a TestCase class has no tests
50
+ def test_em_comm_inactivity_timeout_not_implemented
51
+ assert true
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,125 @@
1
+ require 'em_test_helper'
2
+ require 'socket'
3
+
4
+ class TestIPv4 < Test::Unit::TestCase
5
+
6
+ if Test::Unit::TestCase.public_ipv4?
7
+
8
+ # Tries to connect to www.google.com port 80 via TCP.
9
+ # Timeout in 2 seconds.
10
+ def test_ipv4_tcp_client
11
+ conn = nil
12
+ setup_timeout(2)
13
+
14
+ EM.run do
15
+ conn = EM::connect("www.google.com", 80) do |c|
16
+ def c.connected
17
+ @connected
18
+ end
19
+
20
+ def c.connection_completed
21
+ @connected = true
22
+ EM.stop
23
+ end
24
+ end
25
+ end
26
+
27
+ assert conn.connected
28
+ end
29
+
30
+ # Runs a TCP server in the local IPv4 address, connects to it and sends a specific data.
31
+ # Timeout in 2 seconds.
32
+ def test_ipv4_tcp_local_server
33
+ @@received_data = nil
34
+ @local_port = next_port
35
+ setup_timeout(2)
36
+
37
+ EM.run do
38
+ EM::start_server(@@public_ipv4, @local_port) do |s|
39
+ def s.receive_data data
40
+ @@received_data = data
41
+ EM.stop
42
+ end
43
+ end
44
+
45
+ EM::connect(@@public_ipv4, @local_port) do |c|
46
+ c.send_data "ipv4/tcp"
47
+ end
48
+ end
49
+
50
+ assert_equal "ipv4/tcp", @@received_data
51
+ end
52
+
53
+ # Runs a UDP server in the local IPv4 address, connects to it and sends a specific data.
54
+ # Timeout in 2 seconds.
55
+ def test_ipv4_udp_local_server
56
+ @@received_data = nil
57
+ @local_port = next_port
58
+ setup_timeout(2)
59
+
60
+ EM.run do
61
+ EM::open_datagram_socket(@@public_ipv4, @local_port) do |s|
62
+ def s.receive_data data
63
+ @@received_data = data
64
+ EM.stop
65
+ end
66
+ end
67
+
68
+ EM::open_datagram_socket(@@public_ipv4, next_port) do |c|
69
+ c.send_datagram "ipv4/udp", @@public_ipv4, @local_port
70
+ end
71
+ end
72
+
73
+ assert_equal "ipv4/udp", @@received_data
74
+ end
75
+
76
+ # Try to connect via TCP to an invalid IPv4. EM.connect should raise
77
+ # EM::ConnectionError.
78
+ def test_tcp_connect_to_invalid_ipv4
79
+ invalid_ipv4 = "9.9:9"
80
+
81
+ EM.run do
82
+ begin
83
+ error = nil
84
+ EM.connect(invalid_ipv4, 1234)
85
+ rescue => e
86
+ error = e
87
+ ensure
88
+ EM.stop
89
+ assert_equal EM::ConnectionError, (error && error.class)
90
+ end
91
+ end
92
+ end
93
+
94
+ # Try to send a UDP datagram to an invalid IPv4. EM.send_datagram should raise
95
+ # EM::ConnectionError.
96
+ def test_udp_send_datagram_to_invalid_ipv4
97
+ invalid_ipv4 = "9.9:9"
98
+
99
+ EM.run do
100
+ begin
101
+ error = nil
102
+ EM.open_datagram_socket(@@public_ipv4, next_port) do |c|
103
+ c.send_datagram "hello", invalid_ipv4, 1234
104
+ end
105
+ rescue => e
106
+ error = e
107
+ ensure
108
+ EM.stop
109
+ assert_equal EM::ConnectionError, (error && error.class)
110
+ end
111
+ end
112
+ end
113
+
114
+
115
+ else
116
+ warn "no IPv4 in this host, skipping tests in #{__FILE__}"
117
+
118
+ # Because some rubies will complain if a TestCase class has no tests
119
+ def test_ipv4_unavailable
120
+ assert true
121
+ end
122
+
123
+ end
124
+
125
+ end
@@ -0,0 +1,131 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestIPv6 < Test::Unit::TestCase
4
+
5
+ if Test::Unit::TestCase.public_ipv6?
6
+
7
+ # Tries to connect to ipv6.google.com (2607:f8b0:4010:800::1006) port 80 via TCP.
8
+ # Timeout in 6 seconds.
9
+ def test_ipv6_tcp_client_with_ipv6_google_com
10
+ conn = nil
11
+ setup_timeout(6)
12
+
13
+ EM.run do
14
+ conn = EM::connect("2607:f8b0:4010:800::1006", 80) do |c|
15
+ def c.connected
16
+ @connected
17
+ end
18
+
19
+ def c.unbind(reason)
20
+ warn "unbind: #{reason.inspect}" if reason # XXX at least find out why it failed
21
+ end
22
+
23
+ def c.connection_completed
24
+ @connected = true
25
+ EM.stop
26
+ end
27
+ end
28
+ end
29
+
30
+ assert conn.connected
31
+ end
32
+
33
+ # Runs a TCP server in the local IPv6 address, connects to it and sends a specific data.
34
+ # Timeout in 2 seconds.
35
+ def test_ipv6_tcp_local_server
36
+ @@received_data = nil
37
+ @local_port = next_port
38
+ setup_timeout(2)
39
+
40
+ EM.run do
41
+ EM.start_server(@@public_ipv6, @local_port) do |s|
42
+ def s.receive_data data
43
+ @@received_data = data
44
+ EM.stop
45
+ end
46
+ end
47
+
48
+ EM::connect(@@public_ipv6, @local_port) do |c|
49
+ def c.unbind(reason)
50
+ warn "unbind: #{reason.inspect}" if reason # XXX at least find out why it failed
51
+ end
52
+ c.send_data "ipv6/tcp"
53
+ end
54
+ end
55
+
56
+ assert_equal "ipv6/tcp", @@received_data
57
+ end
58
+
59
+ # Runs a UDP server in the local IPv6 address, connects to it and sends a specific data.
60
+ # Timeout in 2 seconds.
61
+ def test_ipv6_udp_local_server
62
+ @@received_data = nil
63
+ @local_port = next_port
64
+ setup_timeout(2)
65
+
66
+ EM.run do
67
+ EM.open_datagram_socket(@@public_ipv6, @local_port) do |s|
68
+ def s.receive_data data
69
+ @@received_data = data
70
+ EM.stop
71
+ end
72
+ end
73
+
74
+ EM.open_datagram_socket(@@public_ipv6, next_port) do |c|
75
+ c.send_datagram "ipv6/udp", @@public_ipv6, @local_port
76
+ end
77
+ end
78
+
79
+ assert_equal "ipv6/udp", @@received_data
80
+ end
81
+
82
+ # Try to connect via TCP to an invalid IPv6. EM.connect should raise
83
+ # EM::ConnectionError.
84
+ def test_tcp_connect_to_invalid_ipv6
85
+ invalid_ipv6 = "1:A"
86
+
87
+ EM.run do
88
+ begin
89
+ error = nil
90
+ EM.connect(invalid_ipv6, 1234)
91
+ rescue => e
92
+ error = e
93
+ ensure
94
+ EM.stop
95
+ assert_equal EM::ConnectionError, (error && error.class)
96
+ end
97
+ end
98
+ end
99
+
100
+ # Try to send a UDP datagram to an invalid IPv6. EM.send_datagram should raise
101
+ # EM::ConnectionError.
102
+ def test_udp_send_datagram_to_invalid_ipv6
103
+ invalid_ipv6 = "1:A"
104
+
105
+ EM.run do
106
+ begin
107
+ error = nil
108
+ EM.open_datagram_socket(@@public_ipv6, next_port) do |c|
109
+ c.send_datagram "hello", invalid_ipv6, 1234
110
+ end
111
+ rescue => e
112
+ error = e
113
+ ensure
114
+ EM.stop
115
+ assert_equal EM::ConnectionError, (error && error.class)
116
+ end
117
+ end
118
+ end
119
+
120
+
121
+ else
122
+ warn "no IPv6 in this host, skipping tests in #{__FILE__}"
123
+
124
+ # Because some rubies will complain if a TestCase class has no tests.
125
+ def test_ipv6_unavailable
126
+ assert true
127
+ end
128
+
129
+ end
130
+
131
+ end
@@ -0,0 +1,115 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestIterator < Test::Unit::TestCase
4
+
5
+ def get_time
6
+ EM.current_time.strftime('%H:%M:%S')
7
+ end
8
+
9
+ def test_default_concurrency
10
+ items = {}
11
+ list = 1..10
12
+ EM.run {
13
+ EM::Iterator.new(list).each( proc {|num,iter|
14
+ time = get_time
15
+ items[time] ||= []
16
+ items[time] << num
17
+ EM::Timer.new(1) {iter.next}
18
+ }, proc {EM.stop})
19
+ }
20
+ assert_equal(10, items.keys.size)
21
+ assert_equal(list.to_a.sort, items.values.flatten.sort)
22
+ end
23
+
24
+ def test_default_concurrency_with_a_proc
25
+ items = {}
26
+ list = (1..10).to_a
27
+ original_list = list.dup
28
+ EM.run {
29
+ EM::Iterator.new(proc{list.pop || EM::Iterator::Stop}).each( proc {|num,iter|
30
+ time = get_time
31
+ items[time] ||= []
32
+ items[time] << num
33
+ EM::Timer.new(1) {iter.next}
34
+ }, proc {EM.stop})
35
+ }
36
+ assert_equal(10, items.keys.size)
37
+ assert_equal(original_list.to_a.sort, items.values.flatten.sort)
38
+ end
39
+
40
+ def test_concurrency_bigger_than_list_size
41
+ items = {}
42
+ list = [1,2,3]
43
+ EM.run {
44
+ EM::Iterator.new(list,10).each(proc {|num,iter|
45
+ time = get_time
46
+ items[time] ||= []
47
+ items[time] << num
48
+ EM::Timer.new(1) {iter.next}
49
+ }, proc {EM.stop})
50
+ }
51
+ assert_equal(1, items.keys.size)
52
+ assert_equal(list.to_a.sort, items.values.flatten.sort)
53
+ end
54
+
55
+
56
+ def test_changing_concurrency_affects_active_iteration
57
+ items = {}
58
+ list = 1..25
59
+ EM.run {
60
+ i = EM::Iterator.new(list,5)
61
+ i.each(proc {|num,iter|
62
+ time = get_time
63
+ items[time] ||= []
64
+ items[time] << num
65
+ EM::Timer.new(1) {iter.next}
66
+ }, proc {EM.stop})
67
+ EM.add_timer(1){
68
+ i.concurrency = 1
69
+ }
70
+ EM.add_timer(3){
71
+ i.concurrency = 3
72
+ }
73
+ }
74
+ assert_equal(9, items.keys.size)
75
+ assert_equal(list.to_a.sort, items.values.flatten.sort)
76
+ end
77
+
78
+ def test_map
79
+ list = 100..150
80
+ EM.run {
81
+ EM::Iterator.new(list).map(proc{ |num,iter|
82
+ EM.add_timer(0.01){ iter.return(num) }
83
+ }, proc{ |results|
84
+ assert_equal(list.to_a.size, results.size)
85
+ EM.stop
86
+ })
87
+ }
88
+ end
89
+
90
+ def test_inject
91
+ omit_if(windows?)
92
+
93
+ list = %w[ pwd uptime uname date ]
94
+ EM.run {
95
+ EM::Iterator.new(list, 2).inject({}, proc{ |hash,cmd,iter|
96
+ EM.system(cmd){ |output,status|
97
+ hash[cmd] = status.exitstatus == 0 ? output.strip : nil
98
+ iter.return(hash)
99
+ }
100
+ }, proc{ |results|
101
+ assert_equal(results.keys.sort, list.sort)
102
+ EM.stop
103
+ })
104
+ }
105
+ end
106
+
107
+ def test_concurrency_is_0
108
+ EM.run {
109
+ assert_raise ArgumentError do
110
+ EM::Iterator.new(1..5,0)
111
+ end
112
+ EM.stop
113
+ }
114
+ end
115
+ end