diff src/testdir/test_channel.vim @ 7916:54602dcac207 v7.4.1254

commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 3 23:25:07 2016 +0100 patch 7.4.1254 Problem: Opening a second channel causes a crash. (Ken Takata) Solution: Don't re-allocate the array with channels.
author Christian Brabandt <cb@256bit.org>
date Wed, 03 Feb 2016 23:30:04 +0100
parents 35973ce58c84
children ce5a7a613867
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -17,6 +17,8 @@ else
   finish
 endif
 
+let s:port = -1
+
 func s:start_server()
   " The Python program writes the port number in Xportnr.
   call delete("Xportnr")
@@ -49,9 +51,9 @@ func s:start_server()
     call assert_false(1, "Can't start test_channel.py")
     return -1
   endif
-  let port = l[0]
+  let s:port = l[0]
 
-  let handle = ch_open('localhost:' . port, 'json')
+  let handle = ch_open('localhost:' . s:port, 'json')
   return handle
 endfunc
 
@@ -94,6 +96,24 @@ func Test_communicate()
   call s:kill_server()
 endfunc
 
+" Test that we can open two channels.
+func Test_two_channels()
+  let handle = s:start_server()
+  if handle < 0
+    return
+  endif
+  call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
+
+  let newhandle = ch_open('localhost:' . s:port, 'json')
+  call assert_equal('got it', ch_sendexpr(newhandle, 'hello!'))
+  call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
+
+  call ch_close(handle)
+  call assert_equal('got it', ch_sendexpr(newhandle, 'hello!'))
+
+  call s:kill_server()
+endfunc
+
 " Test that a server crash is handled gracefully.
 func Test_server_crash()
   let handle = s:start_server()