comparison src/testdir/test_channel.vim @ 8017:c59a65524084 v7.4.1303

commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 11 20:48:34 2016 +0100 patch 7.4.1303 Problem: A Funcref is not accepted as a callback. Solution: Make a Funcref work. (Damien)
author Christian Brabandt <cb@256bit.org>
date Thu, 11 Feb 2016 21:00:09 +0100
parents dfae8bce5920
children 1f0f08c601b7
comparison
equal deleted inserted replaced
8016:3c70729873ad 8017:c59a65524084
116 call ch_sendexpr(handle, 'hello!', 's:RequestHandler') 116 call ch_sendexpr(handle, 'hello!', 's:RequestHandler')
117 sleep 10m 117 sleep 10m
118 call assert_equal(handle, s:responseHandle) 118 call assert_equal(handle, s:responseHandle)
119 call assert_equal('got it', s:responseMsg) 119 call assert_equal('got it', s:responseMsg)
120 120
121 let s:responseHandle = -1
122 let s:responseMsg = ''
123 call ch_sendexpr(handle, 'hello!', function('s:RequestHandler'))
124 sleep 10m
125 call assert_equal(handle, s:responseHandle)
126 call assert_equal('got it', s:responseMsg)
127
121 " Send an eval request that works. 128 " Send an eval request that works.
122 call assert_equal('ok', ch_sendexpr(handle, 'eval-works')) 129 call assert_equal('ok', ch_sendexpr(handle, 'eval-works'))
123 sleep 10m 130 sleep 10m
124 call assert_equal([-1, 'foo123'], ch_sendexpr(handle, 'eval-result')) 131 call assert_equal([-1, 'foo123'], ch_sendexpr(handle, 'eval-result'))
125 132
204 call s:run_server('s:server_crash') 211 call s:run_server('s:server_crash')
205 endfunc 212 endfunc
206 213
207 let s:reply = "" 214 let s:reply = ""
208 func s:Handler(chan, msg) 215 func s:Handler(chan, msg)
216 unlet s:reply
209 let s:reply = a:msg 217 let s:reply = a:msg
210 endfunc 218 endfunc
211 219
212 func s:channel_handler(port) 220 func s:channel_handler(port)
213 let chopt = copy(s:chopt) 221 let handle = ch_open('localhost:' . a:port, s:chopt)
214 let chopt['callback'] = 's:Handler'
215 let handle = ch_open('localhost:' . a:port, chopt)
216 if handle < 0 222 if handle < 0
217 call assert_false(1, "Can't open channel") 223 call assert_false(1, "Can't open channel")
218 return 224 return
219 endif 225 endif
220 226
228 sleep 10m 234 sleep 10m
229 call assert_equal('we did call you', s:reply) 235 call assert_equal('we did call you', s:reply)
230 endfunc 236 endfunc
231 237
232 func Test_channel_handler() 238 func Test_channel_handler()
239 let s:chopt.callback = 's:Handler'
233 call s:run_server('s:channel_handler') 240 call s:run_server('s:channel_handler')
241 let s:chopt.callback = function('s:Handler')
242 call s:run_server('s:channel_handler')
243 unlet s:chopt.callback
234 endfunc 244 endfunc
235 245
236 " Test that trying to connect to a non-existing port fails quickly. 246 " Test that trying to connect to a non-existing port fails quickly.
237 func Test_connect_waittime() 247 func Test_connect_waittime()
238 let start = reltime() 248 let start = reltime()