Mercurial > vim
diff src/testdir/test_channel.vim @ 8009:b2cfa3416ba0 v7.4.1299
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 10 21:07:14 2016 +0100
patch 7.4.1299
Problem: When the server sends a message with ID zero the channel handler
is not invoked. (Christian J. Robinson)
Solution: Recognize zero value for the request ID. Add a test for invoking
the channel handler.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 10 Feb 2016 21:15:04 +0100 |
parents | ac78cba9e72b |
children | dfae8bce5920 |
line wrap: on
line diff
--- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -204,6 +204,35 @@ func Test_server_crash() call s:run_server('s:server_crash') endfunc +let s:reply = "" +func s:Handler(chan, msg) + let s:reply = a:msg +endfunc + +func s:channel_handler(port) + let chopt = copy(s:chopt) + let chopt['callback'] = 's:Handler' + let handle = ch_open('localhost:' . a:port, chopt) + if handle < 0 + call assert_false(1, "Can't open channel") + return + endif + + " Test that it works while waiting on a numbered message. + call assert_equal('ok', ch_sendexpr(handle, 'call me')) + sleep 10m + call assert_equal('we called you', s:reply) + + " Test that it works while not waiting on a numbered message. + call ch_sendexpr(handle, 'call me again', 0) + sleep 10m + call assert_equal('we did call you', s:reply) +endfunc + +func Test_channel_handler() + call s:run_server('s:channel_handler') +endfunc + " Test that trying to connect to a non-existing port fails quickly. func Test_connect_waittime() let start = reltime()