patch 7.4.1341
Problem: It's difficult to add more arguments to ch_sendraw() and
ch_sendexpr().
Solution: Make the third option a dictionary.
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index e9c2a98..7cd32c8 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -117,7 +117,7 @@
call assert_equal('added more', getline('$'))
" Send a request with a specific handler.
- call ch_sendexpr(handle, 'hello!', 's:RequestHandler')
+ call ch_sendexpr(handle, 'hello!', {'callback': 's:RequestHandler'})
sleep 10m
if !exists('s:responseHandle')
call assert_false(1, 's:responseHandle was not set')
@@ -128,7 +128,7 @@
unlet s:responseHandle
let s:responseMsg = ''
- call ch_sendexpr(handle, 'hello!', function('s:RequestHandler'))
+ call ch_sendexpr(handle, 'hello!', {'callback': function('s:RequestHandler')})
sleep 10m
if !exists('s:responseHandle')
call assert_false(1, 's:responseHandle was not set')
@@ -171,7 +171,7 @@
call assert_equal('ok', ch_sendexpr(handle, 'empty-request'))
" make the server quit, can't check if this works, should not hang.
- call ch_sendexpr(handle, '!quit!', 0)
+ call ch_sendexpr(handle, '!quit!', {'callback': 0})
endfunc
func Test_communicate()
@@ -242,7 +242,7 @@
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)
+ call ch_sendexpr(handle, 'call me again', {'callback': 0})
sleep 10m
call assert_equal('we did call you', s:reply)
endfunc
@@ -292,11 +292,11 @@
call assert_equal("run", job_status(job))
try
let handle = job_getchannel(job)
- call ch_sendraw(handle, "echo something\n", 0)
+ call ch_sendraw(handle, "echo something\n", {'callback': 0})
let msg = ch_readraw(handle)
call assert_equal("something\n", substitute(msg, "\r", "", 'g'))
- call ch_sendraw(handle, "double this\n", 0)
+ call ch_sendraw(handle, "double this\n", {'callback': 0})
let msg = ch_readraw(handle)
call assert_equal("this\nAND this\n", substitute(msg, "\r", "", 'g'))
@@ -315,10 +315,10 @@
call assert_equal("run", job_status(job))
try
let handle = job_getchannel(job)
- call ch_sendraw(handle, "echo something\n", 0)
+ call ch_sendraw(handle, "echo something\n", {'callback': 0})
call assert_equal("something", ch_readraw(handle))
- call ch_sendraw(handle, "double this\n", 0)
+ call ch_sendraw(handle, "double this\n", {'callback': 0})
call assert_equal("this", ch_readraw(handle))
call assert_equal("AND this", ch_readraw(handle))
@@ -340,7 +340,7 @@
" Test that "unlet handle" in a handler doesn't crash Vim.
func s:unlet_handle(port)
let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
- call ch_sendexpr(s:channelfd, "test", function('s:UnletHandler'))
+ call ch_sendexpr(s:channelfd, "test", {'callback': function('s:UnletHandler')})
sleep 10m
call assert_equal('what?', s:unletResponse)
endfunc
@@ -360,7 +360,7 @@
" Test that "unlet handle" in a handler doesn't crash Vim.
func s:close_handle(port)
let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
- call ch_sendexpr(s:channelfd, "test", function('s:CloseHandler'))
+ call ch_sendexpr(s:channelfd, "test", {'callback': function('s:CloseHandler')})
sleep 10m
call assert_equal('what?', s:unletResponse)
endfunc