wj_eventmachine 1.3.0.dev.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +179 -0
  3. data/GNU +281 -0
  4. data/LICENSE +60 -0
  5. data/README.md +110 -0
  6. data/docs/DocumentationGuidesIndex.md +27 -0
  7. data/docs/GettingStarted.md +520 -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 +52 -0
  35. data/ext/cmain.cpp +1046 -0
  36. data/ext/ed.cpp +2238 -0
  37. data/ext/ed.h +460 -0
  38. data/ext/em.cpp +2378 -0
  39. data/ext/em.h +266 -0
  40. data/ext/eventmachine.h +152 -0
  41. data/ext/extconf.rb +285 -0
  42. data/ext/fastfilereader/extconf.rb +120 -0
  43. data/ext/fastfilereader/mapper.cpp +214 -0
  44. data/ext/fastfilereader/mapper.h +59 -0
  45. data/ext/fastfilereader/rubymain.cpp +126 -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 +174 -0
  51. data/ext/rubymain.cpp +1610 -0
  52. data/ext/ssl.cpp +627 -0
  53. data/ext/ssl.h +103 -0
  54. data/ext/wait_for_single_fd.h +36 -0
  55. data/java/.classpath +8 -0
  56. data/java/.project +17 -0
  57. data/java/src/com/rubyeventmachine/EmReactor.java +625 -0
  58. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  59. data/java/src/com/rubyeventmachine/EmReactorInterface.java +70 -0
  60. data/java/src/com/rubyeventmachine/EventableChannel.java +72 -0
  61. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +201 -0
  62. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +415 -0
  63. data/java/src/com/rubyeventmachine/NullEmReactor.java +157 -0
  64. data/java/src/com/rubyeventmachine/NullEventableChannel.java +81 -0
  65. data/lib/em/buftok.rb +59 -0
  66. data/lib/em/callback.rb +58 -0
  67. data/lib/em/channel.rb +69 -0
  68. data/lib/em/completion.rb +307 -0
  69. data/lib/em/connection.rb +776 -0
  70. data/lib/em/deferrable.rb +210 -0
  71. data/lib/em/deferrable/pool.rb +2 -0
  72. data/lib/em/file_watch.rb +73 -0
  73. data/lib/em/future.rb +61 -0
  74. data/lib/em/io_streamer.rb +68 -0
  75. data/lib/em/iterator.rb +252 -0
  76. data/lib/em/messages.rb +66 -0
  77. data/lib/em/pool.rb +151 -0
  78. data/lib/em/process_watch.rb +45 -0
  79. data/lib/em/processes.rb +123 -0
  80. data/lib/em/protocols.rb +37 -0
  81. data/lib/em/protocols/header_and_content.rb +138 -0
  82. data/lib/em/protocols/httpclient.rb +303 -0
  83. data/lib/em/protocols/httpclient2.rb +602 -0
  84. data/lib/em/protocols/line_and_text.rb +125 -0
  85. data/lib/em/protocols/line_protocol.rb +33 -0
  86. data/lib/em/protocols/linetext2.rb +179 -0
  87. data/lib/em/protocols/memcache.rb +331 -0
  88. data/lib/em/protocols/object_protocol.rb +46 -0
  89. data/lib/em/protocols/postgres3.rb +246 -0
  90. data/lib/em/protocols/saslauth.rb +175 -0
  91. data/lib/em/protocols/smtpclient.rb +394 -0
  92. data/lib/em/protocols/smtpserver.rb +666 -0
  93. data/lib/em/protocols/socks4.rb +66 -0
  94. data/lib/em/protocols/stomp.rb +205 -0
  95. data/lib/em/protocols/tcptest.rb +54 -0
  96. data/lib/em/pure_ruby.rb +1299 -0
  97. data/lib/em/queue.rb +80 -0
  98. data/lib/em/resolver.rb +232 -0
  99. data/lib/em/spawnable.rb +84 -0
  100. data/lib/em/streamer.rb +118 -0
  101. data/lib/em/threaded_resource.rb +90 -0
  102. data/lib/em/tick_loop.rb +85 -0
  103. data/lib/em/timers.rb +61 -0
  104. data/lib/em/version.rb +3 -0
  105. data/lib/eventmachine.rb +1602 -0
  106. data/lib/jeventmachine.rb +318 -0
  107. data/rakelib/package.rake +120 -0
  108. data/rakelib/test.rake +6 -0
  109. data/rakelib/test_pure.rake +11 -0
  110. data/tests/client.crt +31 -0
  111. data/tests/client.key +51 -0
  112. data/tests/dhparam.pem +13 -0
  113. data/tests/em_ssl_handlers.rb +153 -0
  114. data/tests/em_test_helper.rb +198 -0
  115. data/tests/jruby/test_jeventmachine.rb +38 -0
  116. data/tests/test_attach.rb +199 -0
  117. data/tests/test_basic.rb +321 -0
  118. data/tests/test_channel.rb +75 -0
  119. data/tests/test_completion.rb +178 -0
  120. data/tests/test_connection_count.rb +83 -0
  121. data/tests/test_connection_write.rb +35 -0
  122. data/tests/test_defer.rb +35 -0
  123. data/tests/test_deferrable.rb +35 -0
  124. data/tests/test_epoll.rb +141 -0
  125. data/tests/test_error_handler.rb +38 -0
  126. data/tests/test_exc.rb +37 -0
  127. data/tests/test_file_watch.rb +86 -0
  128. data/tests/test_fork.rb +75 -0
  129. data/tests/test_futures.rb +170 -0
  130. data/tests/test_handler_check.rb +35 -0
  131. data/tests/test_hc.rb +155 -0
  132. data/tests/test_httpclient.rb +238 -0
  133. data/tests/test_httpclient2.rb +132 -0
  134. data/tests/test_idle_connection.rb +31 -0
  135. data/tests/test_inactivity_timeout.rb +102 -0
  136. data/tests/test_io_streamer.rb +47 -0
  137. data/tests/test_ipv4.rb +96 -0
  138. data/tests/test_ipv6.rb +107 -0
  139. data/tests/test_iterator.rb +122 -0
  140. data/tests/test_kb.rb +28 -0
  141. data/tests/test_keepalive.rb +113 -0
  142. data/tests/test_line_protocol.rb +33 -0
  143. data/tests/test_ltp.rb +155 -0
  144. data/tests/test_ltp2.rb +332 -0
  145. data/tests/test_many_fds.rb +21 -0
  146. data/tests/test_next_tick.rb +104 -0
  147. data/tests/test_object_protocol.rb +36 -0
  148. data/tests/test_pause.rb +109 -0
  149. data/tests/test_pending_connect_timeout.rb +52 -0
  150. data/tests/test_pool.rb +196 -0
  151. data/tests/test_process_watch.rb +50 -0
  152. data/tests/test_processes.rb +128 -0
  153. data/tests/test_proxy_connection.rb +180 -0
  154. data/tests/test_pure.rb +156 -0
  155. data/tests/test_queue.rb +64 -0
  156. data/tests/test_resolver.rb +129 -0
  157. data/tests/test_running.rb +14 -0
  158. data/tests/test_sasl.rb +46 -0
  159. data/tests/test_send_file.rb +217 -0
  160. data/tests/test_servers.rb +32 -0
  161. data/tests/test_shutdown_hooks.rb +23 -0
  162. data/tests/test_smtpclient.rb +75 -0
  163. data/tests/test_smtpserver.rb +90 -0
  164. data/tests/test_sock_opt.rb +53 -0
  165. data/tests/test_spawn.rb +290 -0
  166. data/tests/test_ssl_args.rb +41 -0
  167. data/tests/test_ssl_dhparam.rb +57 -0
  168. data/tests/test_ssl_ecdh_curve.rb +57 -0
  169. data/tests/test_ssl_extensions.rb +24 -0
  170. data/tests/test_ssl_methods.rb +31 -0
  171. data/tests/test_ssl_protocols.rb +190 -0
  172. data/tests/test_ssl_verify.rb +52 -0
  173. data/tests/test_stomp.rb +38 -0
  174. data/tests/test_system.rb +46 -0
  175. data/tests/test_threaded_resource.rb +68 -0
  176. data/tests/test_tick_loop.rb +58 -0
  177. data/tests/test_timers.rb +150 -0
  178. data/tests/test_ud.rb +8 -0
  179. data/tests/test_unbind_reason.rb +40 -0
  180. metadata +384 -0
@@ -0,0 +1,64 @@
1
+ require_relative 'em_test_helper'
2
+
3
+ class TestEMQueue < Test::Unit::TestCase
4
+ def test_queue_push
5
+ s = 0
6
+ EM.run do
7
+ q = EM::Queue.new
8
+ q.push(1)
9
+ EM.next_tick { s = q.size; EM.stop }
10
+ end
11
+ assert_equal 1, s
12
+ end
13
+
14
+ def test_queue_pop
15
+ x,y,z = nil
16
+ EM.run do
17
+ q = EM::Queue.new
18
+ q.push(1,2,3)
19
+ q.pop { |v| x = v }
20
+ q.pop { |v| y = v }
21
+ q.pop { |v| z = v; EM.stop }
22
+ end
23
+ assert_equal 1, x
24
+ assert_equal 2, y
25
+ assert_equal 3, z
26
+ end
27
+
28
+ def test_queue_reactor_thread
29
+ q = EM::Queue.new
30
+
31
+ Thread.new { q.push(1,2,3) }.join
32
+ assert q.empty?
33
+ EM.run { EM.next_tick { EM.stop } }
34
+ assert_equal 3, q.size
35
+
36
+ x = nil
37
+ Thread.new { q.pop { |v| x = v } }.join
38
+ assert_equal nil, x
39
+ EM.run { EM.next_tick { EM.stop } }
40
+ assert_equal 1, x
41
+ end
42
+
43
+ def test_num_waiting
44
+ q = EM::Queue.new
45
+ many = 3
46
+ many.times { q.pop {} }
47
+ EM.run { EM.next_tick { EM.stop } }
48
+ assert_equal many, q.num_waiting
49
+ end
50
+
51
+ def test_big_queue
52
+ EM.run do
53
+ q = EM::Queue.new
54
+ 2000.times do |i|
55
+ q.push(*0..1000)
56
+ q.pop { |v| assert_equal v, i % 1001 }
57
+ end
58
+ q.pop do
59
+ assert_equal 1_999_999, q.size
60
+ EM.stop
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,129 @@
1
+ require_relative 'em_test_helper'
2
+
3
+ class TestResolver < Test::Unit::TestCase
4
+
5
+ # always true unless set
6
+ CI_WINDOWS = windows? && ENV.fetch('CI', 'true').casecmp('true').zero?
7
+
8
+ def ci_windows_retries(err)
9
+ if CI_WINDOWS and err.is_a? String and err[/retries exceeded/]
10
+ EM.stop
11
+ notify 'Intermittent Appveyor DNS error: retries exceeded'
12
+ true
13
+ else
14
+ false
15
+ end
16
+ end
17
+
18
+ def test_nameserver
19
+ assert_kind_of(String, EM::DNS::Resolver.nameserver)
20
+ end
21
+
22
+ def test_nameservers
23
+ assert_kind_of(Array, EM::DNS::Resolver.nameservers)
24
+ end
25
+
26
+ def test_hosts
27
+ assert_kind_of(Hash, EM::DNS::Resolver.hosts)
28
+
29
+ # Make sure that blank or comment lines are skipped
30
+ refute(EM::DNS::Resolver.hosts.include? nil)
31
+ end
32
+
33
+ def test_a
34
+ pend('FIXME: this test is broken on Windows') if windows? && RUBY_VERSION < "2.4"
35
+
36
+ EM.run {
37
+ d = EM::DNS::Resolver.resolve "example.com"
38
+ d.errback { |err|
39
+ return if ci_windows_retries err
40
+ assert false, "failed to resolve example.com: #{err}"
41
+ }
42
+ d.callback { |r|
43
+ assert r
44
+ EM.stop
45
+ }
46
+ }
47
+ end
48
+
49
+ def test_bad_host
50
+ EM.run {
51
+ d = EM::DNS::Resolver.resolve "asdfasasdf"
52
+ d.callback { assert false }
53
+ d.errback { assert true; EM.stop }
54
+ }
55
+ end
56
+
57
+ def test_garbage
58
+ assert_raises( ArgumentError ) {
59
+ EM.run {
60
+ EM::DNS::Resolver.resolve 123
61
+ }
62
+ }
63
+ end
64
+
65
+ # There isn't a public DNS entry like 'example.com' with an A rrset
66
+ def test_a_pair
67
+ pend('FIXME: this test is broken on Windows') if windows? && RUBY_VERSION < "2.4"
68
+
69
+ EM.run {
70
+ d = EM::DNS::Resolver.resolve "yahoo.com"
71
+ d.errback { |err|
72
+ return if ci_windows_retries err
73
+ assert false, "failed to resolve yahoo.com: #{err}"
74
+ }
75
+ d.callback { |r|
76
+ assert_kind_of(Array, r)
77
+ assert r.size > 1, "returned #{r.size} results: #{r.inspect}"
78
+ EM.stop
79
+ }
80
+ }
81
+ end
82
+
83
+ def test_localhost
84
+ pend('FIXME: this test is broken on Windows') if windows?
85
+
86
+ EM.run {
87
+ d = EM::DNS::Resolver.resolve "localhost"
88
+ d.errback { assert false }
89
+ d.callback { |r|
90
+ # "127.0.1.1" added for testing on bionic 18.04
91
+ assert_include(["127.0.0.1", "127.0.1.1", "::1"], r.first)
92
+ assert_kind_of(Array, r)
93
+
94
+ EM.stop
95
+ }
96
+ }
97
+ end
98
+
99
+ def test_timer_cleanup
100
+ pend('FIXME: this test is broken on Windows') if windows? && RUBY_VERSION < "2.4"
101
+
102
+ EM.run {
103
+ d = EM::DNS::Resolver.resolve "example.com"
104
+ d.errback { |err|
105
+ return if ci_windows_retries err
106
+ assert false, "failed to resolve example.com: #{err}"
107
+ }
108
+ d.callback { |r|
109
+ # This isn't a great test, but it's hard to get more canonical
110
+ # confirmation that the timer is cancelled
111
+ assert_nil(EM::DNS::Resolver.socket.instance_variable_get(:@timer))
112
+
113
+ EM.stop
114
+ }
115
+ }
116
+ end
117
+
118
+ def test_failure_timer_cleanup
119
+ EM.run {
120
+ d = EM::DNS::Resolver.resolve "asdfasdf"
121
+ d.callback { assert false }
122
+ d.errback {
123
+ assert_nil(EM::DNS::Resolver.socket.instance_variable_get(:@timer))
124
+
125
+ EM.stop
126
+ }
127
+ }
128
+ end
129
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'em_test_helper'
2
+
3
+ class TestRunning < Test::Unit::TestCase
4
+ def test_running
5
+ assert_equal( false, EM::reactor_running? )
6
+ r = false
7
+ EM.run {
8
+ r = EM::reactor_running?
9
+ EM.stop
10
+ }
11
+ assert_equal( true, r )
12
+ end
13
+ end
14
+
@@ -0,0 +1,46 @@
1
+ require_relative 'em_test_helper'
2
+
3
+ class TestSASL < Test::Unit::TestCase
4
+
5
+ # SASL authentication is usually done with UNIX-domain sockets, but
6
+ # we'll use TCP so this test will work on Windows. As far as the
7
+ # protocol handlers are concerned, there's no difference.
8
+
9
+ TestUser,TestPsw = "someone", "password"
10
+
11
+ class SaslServer < EM::Connection
12
+ include EM::Protocols::SASLauth
13
+ def validate usr, psw, sys, realm
14
+ usr == TestUser and psw == TestPsw
15
+ end
16
+ end
17
+
18
+ class SaslClient < EM::Connection
19
+ include EM::Protocols::SASLauthclient
20
+ end
21
+
22
+ def setup
23
+ @port = next_port
24
+ end
25
+
26
+ def test_sasl
27
+ resp = nil
28
+ EM.run {
29
+ EM.start_server( "127.0.0.1", @port, SaslServer )
30
+
31
+ c = EM.connect( "127.0.0.1", @port, SaslClient )
32
+ d = c.validate?( TestUser, TestPsw )
33
+ d.timeout 1
34
+ d.callback {
35
+ resp = true
36
+ EM.stop
37
+ }
38
+ d.errback {
39
+ resp = false
40
+ EM.stop
41
+ }
42
+ }
43
+ assert_equal( true, resp )
44
+ end
45
+
46
+ end
@@ -0,0 +1,217 @@
1
+ require_relative 'em_test_helper'
2
+ require 'tempfile'
3
+
4
+ class TestSendFile < Test::Unit::TestCase
5
+
6
+ if EM.respond_to?(:send_file_data)
7
+ module TestModule
8
+ def initialize filename
9
+ @filename = filename
10
+ end
11
+
12
+ def post_init
13
+ send_file_data @filename
14
+ close_connection_after_writing
15
+ end
16
+ end
17
+
18
+ module TestClient
19
+ def data_to(&blk)
20
+ @data_to = blk
21
+ end
22
+
23
+ def receive_data(data)
24
+ @data_to.call(data) if @data_to
25
+ end
26
+
27
+ def unbind
28
+ EM.stop
29
+ end
30
+ end
31
+
32
+ def setup
33
+ @file = Tempfile.new("em_test_file")
34
+ @filename = @file.path
35
+ @port = next_port
36
+ end
37
+
38
+ def test_send_file
39
+ File.open( @filename, "w" ) {|f|
40
+ f << ("A" * 5000)
41
+ }
42
+
43
+ data = ''
44
+
45
+ EM.run {
46
+ EM.start_server "127.0.0.1", @port, TestModule, @filename
47
+ setup_timeout
48
+
49
+ EM.connect "127.0.0.1", @port, TestClient do |c|
50
+ c.data_to { |d| data << d }
51
+ end
52
+ }
53
+
54
+ assert_equal( "A" * 5000, data )
55
+ end
56
+
57
+ # EM::Connection#send_file_data has a strict upper limit on the filesize it will work with.
58
+ def test_send_large_file
59
+ File.open( @filename, "w" ) {|f|
60
+ f << ("A" * 1000000)
61
+ }
62
+
63
+ data = ''
64
+
65
+ assert_raises(RuntimeError) {
66
+ EM.run {
67
+ EM.start_server "127.0.0.1", @port, TestModule, @filename
68
+ setup_timeout
69
+ EM.connect "127.0.0.1", @port, TestClient do |c|
70
+ c.data_to { |d| data << d }
71
+ end
72
+ }
73
+ }
74
+ end
75
+
76
+ module StreamTestModule
77
+ def initialize filename
78
+ @filename = filename
79
+ end
80
+
81
+ def post_init
82
+ EM::Deferrable.future( stream_file_data(@filename)) {
83
+ close_connection_after_writing
84
+ }
85
+ end
86
+ end
87
+
88
+ module ChunkStreamTestModule
89
+ def initialize filename
90
+ @filename = filename
91
+ end
92
+
93
+ def post_init
94
+ EM::Deferrable.future( stream_file_data(@filename, :http_chunks=>true)) {
95
+ close_connection_after_writing
96
+ }
97
+ end
98
+ end
99
+
100
+ def test_stream_file_data
101
+ File.open( @filename, "w" ) {|f|
102
+ f << ("A" * 1000)
103
+ }
104
+
105
+ data = ''
106
+
107
+ EM.run {
108
+ EM.start_server "127.0.0.1", @port, StreamTestModule, @filename
109
+ setup_timeout
110
+ EM.connect "127.0.0.1", @port, TestClient do |c|
111
+ c.data_to { |d| data << d }
112
+ end
113
+ }
114
+
115
+ assert_equal( "A" * 1000, data )
116
+ end
117
+
118
+ def test_stream_chunked_file_data
119
+ File.open( @filename, "w" ) {|f|
120
+ f << ("A" * 1000)
121
+ }
122
+
123
+ data = ''
124
+
125
+ EM.run {
126
+ EM.start_server "127.0.0.1", @port, ChunkStreamTestModule, @filename
127
+ setup_timeout
128
+ EM.connect "127.0.0.1", @port, TestClient do |c|
129
+ c.data_to { |d| data << d }
130
+ end
131
+ }
132
+
133
+ assert_equal( "3e8\r\n#{"A" * 1000}\r\n0\r\n\r\n", data )
134
+ end
135
+
136
+ module BadFileTestModule
137
+ def initialize filename
138
+ @filename = filename
139
+ end
140
+
141
+ def post_init
142
+ de = stream_file_data( @filename+".wrong" )
143
+ de.errback {|msg|
144
+ send_data msg
145
+ close_connection_after_writing
146
+ }
147
+ end
148
+ end
149
+ def test_stream_bad_file
150
+ data = ''
151
+ EM.run {
152
+ EM.start_server "127.0.0.1", @port, BadFileTestModule, @filename
153
+ setup_timeout(5)
154
+ EM.connect "127.0.0.1", @port, TestClient do |c|
155
+ c.data_to { |d| data << d }
156
+ end
157
+ }
158
+
159
+ assert_equal( "file not found", data )
160
+ end
161
+ else
162
+ warn "EM.send_file_data not implemented, skipping tests in #{__FILE__}"
163
+
164
+ # Because some rubies will complain if a TestCase class has no tests
165
+ def test_em_send_file_data_not_implemented
166
+ assert !EM.respond_to?(:send_file_data)
167
+ end
168
+ end
169
+
170
+ begin
171
+ require 'fastfilereaderext'
172
+
173
+ def test_stream_large_file_data
174
+ File.open( @filename, "w" ) {|f|
175
+ f << ("A" * 10000)
176
+ }
177
+
178
+ data = ''
179
+
180
+ EM.run {
181
+ EM.start_server "127.0.0.1", @port, StreamTestModule, @filename
182
+ setup_timeout(darwin? ? 0.5 : 0.25)
183
+ EM.connect "127.0.0.1", @port, TestClient do |c|
184
+ c.data_to { |d| data << d }
185
+ end
186
+ }
187
+
188
+ assert_equal( "A" * 10000, data )
189
+ end
190
+
191
+ def test_stream_large_chunked_file_data
192
+ File.open( @filename, "w" ) {|f|
193
+ f << ("A" * 100000)
194
+ }
195
+
196
+ data = ''
197
+
198
+ EM.run {
199
+ EM.start_server "127.0.0.1", @port, ChunkStreamTestModule, @filename
200
+ setup_timeout
201
+ EM.connect "127.0.0.1", @port, TestClient do |c|
202
+ c.data_to { |d| data << d }
203
+ end
204
+ }
205
+
206
+ expected = [
207
+ "4000\r\n#{"A" * 16384}\r\n" * 6,
208
+ "6a0\r\n#{"A" * 0x6a0}\r\n",
209
+ "0\r\n\r\n"
210
+ ].join
211
+ assert_equal( expected, data )
212
+ end
213
+ rescue LoadError
214
+ warn "require 'fastfilereaderext' failed, skipping tests in #{__FILE__}"
215
+ end
216
+
217
+ end