summaryrefslogtreecommitdiff
path: root/src/testdir/test_channel.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_channel.vim')
-rw-r--r--src/testdir/test_channel.vim29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index f0a149d19..e894c09cc 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -83,7 +83,6 @@ func s:kill_server()
endif
endfunc
-let s:responseHandle = -1
let s:responseMsg = ''
func s:RequestHandler(handle, msg)
let s:responseHandle = a:handle
@@ -92,7 +91,7 @@ endfunc
func s:communicate(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
- if handle < 0
+ if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
return
endif
@@ -115,14 +114,22 @@ func s:communicate(port)
" Send a request with a specific handler.
call ch_sendexpr(handle, 'hello!', 's:RequestHandler')
sleep 10m
- call assert_equal(handle, s:responseHandle)
+ if !exists('s:responseHandle')
+ call assert_false(1, 's:responseHandle was not set')
+ else
+ call assert_equal(handle, s:responseHandle)
+ endif
call assert_equal('got it', s:responseMsg)
- let s:responseHandle = -1
+ unlet s:responseHandle
let s:responseMsg = ''
call ch_sendexpr(handle, 'hello!', function('s:RequestHandler'))
sleep 10m
- call assert_equal(handle, s:responseHandle)
+ if !exists('s:responseHandle')
+ call assert_false(1, 's:responseHandle was not set')
+ else
+ call assert_equal(handle, s:responseHandle)
+ endif
call assert_equal('got it', s:responseMsg)
" Send an eval request that works.
@@ -169,7 +176,7 @@ endfunc
" Test that we can open two channels.
func s:two_channels(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
- if handle < 0
+ if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
return
endif
@@ -177,7 +184,7 @@ func s:two_channels(port)
call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
let newhandle = ch_open('localhost:' . a:port, s:chopt)
- if newhandle < 0
+ if ch_status(newhandle) == "fail"
call assert_false(1, "Can't open second channel")
return
endif
@@ -197,7 +204,7 @@ endfunc
" Test that a server crash is handled gracefully.
func s:server_crash(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
- if handle < 0
+ if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
return
endif
@@ -219,7 +226,7 @@ endfunc
func s:channel_handler(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
- if handle < 0
+ if ch_status(handle) == "fail"
call assert_false(1, "Can't open channel")
return
endif
@@ -247,7 +254,7 @@ endfunc
func Test_connect_waittime()
let start = reltime()
let handle = ch_open('localhost:9876', s:chopt)
- if handle >= 0
+ if ch_status(handle) == "fail"
" Oops, port does exists.
call ch_close(handle)
else
@@ -257,7 +264,7 @@ func Test_connect_waittime()
let start = reltime()
let handle = ch_open('localhost:9867', {'waittime': 2000})
- if handle >= 0
+ if ch_status(handle) != "fail"
" Oops, port does exists.
call ch_close(handle)
else