comparison src/testdir/test_channel.vim @ 8222:4f0677020a43 v7.4.1404

commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 23 19:34:01 2016 +0100 patch 7.4.1404 Problem: ch_read() doesn't time out on MS-Windows. Solution: Instead of WM_NETBEANS use select(). (Yukihiro Nakadaira)
author Christian Brabandt <cb@256bit.org>
date Tue, 23 Feb 2016 19:45:05 +0100
parents b717dae2f26d
children e05e28dcb590
comparison
equal deleted inserted replaced
8221:5def36f799a2 8222:4f0677020a43
129 sleep 10m 129 sleep 10m
130 if !exists('s:responseHandle') 130 if !exists('s:responseHandle')
131 call assert_false(1, 's:responseHandle was not set') 131 call assert_false(1, 's:responseHandle was not set')
132 else 132 else
133 call assert_equal(handle, s:responseHandle) 133 call assert_equal(handle, s:responseHandle)
134 unlet s:responseHandle
134 endif 135 endif
135 call assert_equal('got it', s:responseMsg) 136 call assert_equal('got it', s:responseMsg)
136 137
137 unlet s:responseHandle
138 let s:responseMsg = '' 138 let s:responseMsg = ''
139 call ch_sendexpr(handle, 'hello!', {'callback': function('s:RequestHandler')}) 139 call ch_sendexpr(handle, 'hello!', {'callback': function('s:RequestHandler')})
140 sleep 10m 140 sleep 10m
141 if !exists('s:responseHandle') 141 if !exists('s:responseHandle')
142 call assert_false(1, 's:responseHandle was not set') 142 call assert_false(1, 's:responseHandle was not set')
143 else 143 else
144 call assert_equal(handle, s:responseHandle) 144 call assert_equal(handle, s:responseHandle)
145 unlet s:responseHandle
145 endif 146 endif
146 call assert_equal('got it', s:responseMsg) 147 call assert_equal('got it', s:responseMsg)
147 148
148 " check setting options (without testing the effect) 149 " check setting options (without testing the effect)
149 call ch_setoptions(handle, {'callback': 's:NotUsed'}) 150 call ch_setoptions(handle, {'callback': 's:NotUsed'})
184 call assert_equal('ok', ch_sendexpr(handle, 'redraw!')) 185 call assert_equal('ok', ch_sendexpr(handle, 'redraw!'))
185 186
186 call assert_equal('ok', ch_sendexpr(handle, 'empty-request')) 187 call assert_equal('ok', ch_sendexpr(handle, 'empty-request'))
187 188
188 " Reading while there is nothing available. 189 " Reading while there is nothing available.
189 " TODO: make this work for MS-Windows 190 call assert_equal(v:none, ch_read(handle, {'timeout': 0}))
190 if has('unix') 191 let start = reltime()
191 call assert_equal(v:none, ch_read(handle, {'timeout': 0})) 192 call assert_equal(v:none, ch_read(handle, {'timeout': 333}))
192 let start = reltime() 193 let elapsed = reltime(start)
193 call assert_equal(v:none, ch_read(handle, {'timeout': 333})) 194 call assert_true(reltimefloat(elapsed) > 0.3)
194 let elapsed = reltime(start) 195 call assert_true(reltimefloat(elapsed) < 0.6)
195 call assert_true(reltimefloat(elapsed) > 0.3)
196 call assert_true(reltimefloat(elapsed) < 0.6)
197 endif
198 196
199 " Send without waiting for a response, then wait for a response. 197 " Send without waiting for a response, then wait for a response.
200 call ch_sendexpr(handle, 'wait a bit', {'callback': 0}) 198 call ch_sendexpr(handle, 'wait a bit', {'callback': 0})
201 let resp = ch_read(handle) 199 let resp = ch_read(handle)
202 call assert_equal(type([]), type(resp)) 200 call assert_equal(type([]), type(resp))