Lines Matching refs:handle
58 func Ch_requestHandler(handle, msg) argument
59 let g:Ch_responseHandle = a:handle
68 let handle = ch_open(s:localhost . a:port, s:chopt)
69 if ch_status(handle) == "fail"
75 call assert_equal('no process', string(ch_getjob(handle)))
77 let dict = handle->ch_info()
85 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
88 call assert_equal('ok', ch_evalexpr(handle, 'malformed1'))
89 call assert_equal('ok', ch_evalexpr(handle, 'malformed2'))
90 call assert_equal('ok', ch_evalexpr(handle, 'malformed3'))
93 call assert_equal('ok', ch_evalexpr(handle, 'split'))
98 call assert_equal('this][that', ch_evalexpr(handle, 'echo this][that'))
101 call assert_equal(0, ch_canread(handle))
105 call ch_sendexpr(handle, 'echo hello ' . i)
107 call assert_equal('hello 0', ch_read(handle)[1])
108 call assert_equal('hello 1', ch_read(handle)[1])
109 call assert_equal('hello 2', ch_read(handle)[1])
114 call assert_equal('ok', ch_evalexpr(handle, 'make change'))
122 call assert_equal('ok', ch_evalexpr(handle, 'echoerr'))
131 call assert_equal('ok', ch_evalexpr(handle, 'bad command'))
134 call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100}))
138 call ch_sendexpr(handle, 'hello!', {'callback': 'Ch_requestHandler'})
143 call assert_equal(handle, g:Ch_responseHandle)
149 call ch_sendexpr(handle, 'hello!', {'callback': function('Ch_requestHandler')})
154 call assert_equal(handle, g:Ch_responseHandle)
161 call ch_sendexpr(handle, 'hello!', {'callback': {a, b -> Ch_requestHandler(a, b)}})
166 call assert_equal(handle, g:Ch_responseHandle)
171 " Collect garbage, tests that our handle isn't collected.
175 eval handle->ch_setoptions({'callback': 's:NotUsed'})
176 call ch_setoptions(handle, {'timeout': 1111})
177 call ch_setoptions(handle, {'mode': 'json'})
178 call assert_fails("call ch_setoptions(handle, {'waittime': 111})", 'E475:')
179 call ch_setoptions(handle, {'callback': ''})
180 call ch_setoptions(handle, {'drop': 'never'})
181 call ch_setoptions(handle, {'drop': 'auto'})
182 call assert_fails("call ch_setoptions(handle, {'drop': 'bad'})", 'E475:')
183 call assert_equal(0, ch_setoptions(handle, test_null_dict()))
187 call assert_equal('ok', ch_evalexpr(handle, 'eval-works'))
189 call assert_equal([-1, 'foo123'], ch_evalexpr(handle, 'eval-result'))
192 call assert_equal('ok', ch_evalexpr(handle, 'eval-special'))
194 call assert_equal([-2, "foo\x7f\x10\x01bar"], ch_evalexpr(handle, 'eval-result'))
198 call assert_equal('ok', ch_evalexpr(handle, 'eval-getline'))
200 call assert_equal([-3, "a\nb\<CR>c\x01d\x7fe"], ch_evalexpr(handle, 'eval-result'))
203 call assert_equal('ok', ch_evalexpr(handle, 'eval-fails'))
205 call assert_equal([-4, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
208 call assert_equal('ok', ch_evalexpr(handle, 'eval-error'))
210 call assert_equal([-5, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
213 call assert_equal('ok', ch_evalexpr(handle, 'eval-bad'))
215 call assert_equal([-5, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
218 call assert_equal('ok', ch_evalexpr(handle, 'an expr'))
224 call assert_equal('ok', ch_evalexpr(handle, 'redraw'))
225 call assert_equal('ok', ch_evalexpr(handle, 'redraw!'))
227 call assert_equal('ok', ch_evalexpr(handle, 'empty-request'))
230 call assert_equal(v:none, ch_read(handle, {'timeout': 0}))
233 call assert_equal(v:none, ch_read(handle, {'timeout': 333}))
239 call ch_sendexpr(handle, 'wait a bit')
240 let resp = ch_read(handle)
246 call ch_sendexpr(handle, '!quit!')
261 let handle = ch_open(s:localhost . a:port, s:chopt)
262 call assert_equal(v:t_channel, type(handle))
263 if handle->ch_status() == "fail"
268 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
276 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
278 call ch_close(handle)
297 let handle = ch_open(s:localhost . a:port, s:chopt)
298 if ch_status(handle) == "fail"
303 call ch_evalexpr(handle, '!crash!')
326 let handle = ch_open(s:localhost . a:port, s:chopt)
327 if ch_status(handle) == "fail"
333 call assert_equal('ok', ch_evalexpr(handle, 'call me'))
337 call ch_sendexpr(handle, 'call me again')
370 let handle = (s:localhost .. a:port)->ch_open(s:chopt)
371 if ch_status(handle) == "fail"
377 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
381 call assert_equal('sent zero', ch_evalexpr(handle, 'send zero'))
392 call ch_sendexpr(handle, 'send zero', {'callback': 'Ch_oneHandler'})
439 let handle = ch_open(s:localhost . a:port, s:chopt)
440 if ch_status(handle) == "fail"
444 call ch_setoptions(handle, {'mode': 'raw'})
447 call ch_sendraw(handle, "[1, \"hello!\"]\n", {'callback': 'Ch_handleRaw1'})
449 call ch_sendraw(handle, "[2, \"echo something\"]\n", {'callback': 'Ch_handleRaw2'})
450 call ch_sendraw(handle, "[3, \"wait a bit\"]\n", {'callback': 'Ch_handleRaw3'})
473 let handle = ch_open('localhost:9876', s:chopt)
474 if ch_status(handle) != "fail"
476 call ch_close(handle)
487 let handle = ch_open('localhost:9867', {'waittime': 500})
488 if ch_status(handle) != "fail"
490 call ch_close(handle)
537 let g:handle = job->job_getchannel()
538 call WaitFor('g:handle->ch_canread()')
539 unlet g:handle
633 let handle = job_getchannel(job)
634 call ch_sendraw(handle, "echo something\n")
635 call assert_equal("something", handle->ch_readraw())
637 call ch_sendraw(handle, "echoerr wrong\n")
638 call assert_equal("wrong", ch_readraw(handle, {'part': 'err'}))
640 call ch_sendraw(handle, "double this\n")
641 call assert_equal("this", ch_readraw(handle))
642 call assert_equal("AND this", ch_readraw(handle))
644 call ch_sendraw(handle, "split this line\n")
645 call assert_equal("this linethis linethis line", handle->ch_read())
647 let reply = ch_evalraw(handle, "quit\n")
657 " On MS-Windows the server must close the file handle before we are able
670 let handle = job_getchannel(g:job)
671 call assert_equal("something", ch_readraw(handle))
672 call assert_equal("wrong", ch_readraw(handle, {'part': 'err'}))
673 call assert_equal("this", ch_readraw(handle))
674 call assert_equal("AND this", ch_readraw(handle))
687 let handle = job_getchannel(g:job)
688 call ch_sendraw(handle, "echo line one\n")
689 call ch_sendraw(handle, "echo line two\n")
690 call ch_sendraw(handle, "double this\n")
704 let handle = job_getchannel(g:job)
705 call ch_sendraw(handle, "echoerr line one\n")
706 call ch_sendraw(handle, "echoerr line two\n")
707 call ch_sendraw(handle, "doubleerr this\n")
720 let handle = job_getchannel(g:job)
721 call ch_sendraw(handle, "echoerr line one\n")
722 call ch_sendraw(handle, "echo line two\n")
723 call ch_sendraw(handle, "double this\n")
724 call ch_sendraw(handle, "doubleerr that\n")
761 let handle = job_getchannel(job)
762 call ch_sendraw(handle, "echo line one\n")
763 call ch_sendraw(handle, "echo line two\n")
764 call ch_sendraw(handle, "double this\n")
765 call ch_sendraw(handle, "quit\n")
848 let handle = job_getchannel(job)
849 call ch_sendraw(handle, "echoerr line one\n")
850 call ch_sendraw(handle, "echoerr line two\n")
851 call ch_sendraw(handle, "doubleerr this\n")
852 call ch_sendraw(handle, "quit\n")
886 let handle = job_getchannel(job)
887 call assert_equal(bufnr('pipe-err'), ch_getbufnr(handle, 'out'))
888 call assert_equal(bufnr('pipe-err'), ch_getbufnr(handle, 'err'))
890 call ch_sendraw(handle, "echo line one\n")
891 call ch_sendraw(handle, "echoerr line two\n")
892 call ch_sendraw(handle, "double this\n")
893 call ch_sendraw(handle, "doubleerr that\n")
894 call ch_sendraw(handle, "quit\n")
919 let handle = job_getchannel(job)
920 call assert_equal('one', ch_read(handle))
921 call assert_equal('two', ch_read(handle))
922 call assert_equal('three', ch_read(handle))
995 let handle = job_getchannel(job)
996 call ch_sendraw(handle, "echo line one\n")
997 call ch_sendraw(handle, "echo line two\n")
998 exe handle->ch_getbufnr("out") .. 'sbuf'
1014 let handle = job_getchannel(job)
1015 call ch_sendraw(handle, "echo [0, \"hello\"]\n")
1016 call ch_sendraw(handle, "echo [-2, 12.34]\n")
1017 exe ch_getbufnr(handle, "out") . 'sbuf'
1191 let handle = job_getchannel(job)
1193 call ch_sendraw(handle, "echo something\n")
1194 call assert_equal("something", ch_readraw(handle))
1199 let job = job_start(s:python . " test_channel_pipe.py", {'channel': handle})
1201 let handle = job_getchannel(job)
1203 call ch_sendraw(handle, "echo again\n")
1204 call assert_equal("again", ch_readraw(handle))
1389 func s:UnletHandler(handle, msg) argument
1394 " Test that "unlet handle" in a handler doesn't crash Vim.
1413 func Ch_CloseHandler(handle, msg) argument
1418 " Test that "unlet handle" in a handler doesn't crash Vim.
1437 let handle = ch_open('[::1]:' .. a:port, s:chopt)
1438 call assert_notequal('fail', ch_status(handle))
1503 let handle = ch_open(s:localhost . a:port, s:chopt)
1504 if ch_status(handle) == "fail"
1510 call assert_equal('ok', ch_evalexpr(handle, 'call-func'))
1513 call assert_fails("let i = ch_evalexpr(handle, '2 + 2', {'callback' : 'abc'})", 'E917:')
1514 call assert_fails("let i = ch_evalexpr(handle, '2 + 2', {'drop' : ''})", 'E475:')
1603 let handle = ch_open(s:localhost . a:port, s:chopt)
1604 if ch_status(handle) == "fail"
1608 call ch_setoptions(handle, {'close_cb': 'MyCloseCb'})
1610 call assert_equal('', ch_evalexpr(handle, 'close me'))
1624 let handle = ch_open(s:localhost . a:port, s:chopt)
1625 if ch_status(handle) == "fail"
1633 call ch_setoptions(handle, {'close_cb': g:Ch_d.closeCb})
1635 call assert_equal('', ch_evalexpr(handle, 'close me'))
1918 let handle = ch_open(s:localhost . a:port, s:chopt)
1919 if ch_status(handle) == "fail"
1924 call ch_setoptions(handle, {'close_cb': {ch -> execute("let g:Ch_close_ret = 'closed'")}})
1927 call assert_equal('', ch_evalexpr(handle, 'close me'))
2148 let handle = job_getchannel(job)
2149 call ch_sendraw(handle, "echo something\n")
2150 call assert_equal("something", ch_readraw(handle))
2152 call ch_sendraw(handle, "echoerr wrong\n")
2153 call assert_equal("wrong", ch_readraw(handle))