]> granicus.if.org Git - vim/commitdiff
patch 7.4.1504 v7.4.1504
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Mar 2016 20:35:57 +0000 (21:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Mar 2016 20:35:57 +0000 (21:35 +0100)
Problem:    No test for reading last-but-one line.
Solution:   Add a test.

src/testdir/test_channel.vim
src/version.c

index 5133a249654b4e98cc7bbeb468abe6c23e62b694..5321cce23f3ba62a5ee3df84c1ab845ae7065d64 100644 (file)
@@ -629,6 +629,83 @@ func Test_pipe_to_buffer_json()
   endtry
 endfunc
 
+" Wait a little while for the last line, minus "offset", to equal "line".
+func Wait_for_last_line(line, offset)
+  for i in range(100)
+    sleep 10m
+    if getline(line('$') - a:offset) == a:line
+      break
+    endif
+  endfor
+endfunc
+
+func Test_pipe_io_two_buffers()
+  if !has('job')
+    return
+  endif
+  call ch_log('Test_pipe_io_two_buffers()')
+
+  " Create two buffers, one to read from and one to write to.
+  split pipe-output
+  set buftype=nofile
+  split pipe-input
+  set buftype=nofile
+
+  let job = job_start(s:python . " test_channel_pipe.py",
+       \ {'in-io': 'buffer', 'in-name': 'pipe-input', 'in-top': 0,
+       \  'out-io': 'buffer', 'out-name': 'pipe-output'})
+  call assert_equal("run", job_status(job))
+  try
+    exe "normal Gaecho hello\<CR>"
+    exe bufwinnr('pipe-output') . "wincmd w"
+    call Wait_for_last_line('hello', 0)
+    call assert_equal('hello', getline('$'))
+
+    exe bufwinnr('pipe-input') . "wincmd w"
+    exe "normal Gadouble this\<CR>"
+    exe bufwinnr('pipe-output') . "wincmd w"
+    call Wait_for_last_line('AND this', 0)
+    call assert_equal('this', getline(line('$') - 1))
+    call assert_equal('AND this', getline('$'))
+
+    bwipe!
+    exe bufwinnr('pipe-input') . "wincmd w"
+    bwipe!
+  finally
+    call job_stop(job)
+  endtry
+endfunc
+
+func Test_pipe_io_one_buffer()
+  if !has('job')
+    return
+  endif
+  call ch_log('Test_pipe_io_one_buffer()')
+
+  " Create one buffer to read from and to write to.
+  split pipe-io
+  set buftype=nofile
+
+  let job = job_start(s:python . " test_channel_pipe.py",
+       \ {'in-io': 'buffer', 'in-name': 'pipe-io', 'in-top': 0,
+       \  'out-io': 'buffer', 'out-name': 'pipe-io'})
+  call assert_equal("run", job_status(job))
+  try
+    exe "normal Goecho hello\<CR>"
+    call Wait_for_last_line('hello', 1)
+    call assert_equal('hello', getline(line('$') - 1))
+
+    exe "normal Gadouble this\<CR>"
+    call Wait_for_last_line('AND this', 1)
+    call assert_equal('this', getline(line('$') - 2))
+    call assert_equal('AND this', getline(line('$') - 1))
+
+    bwipe!
+  finally
+    call job_stop(job)
+  endtry
+endfunc
+
 """"""""""
 
 let s:unletResponse = ''
index 92fb02a7dd550b5115c46a2b264c1c6bc6aacbb2..1ba0ab0b98a0f2a1f026114de3ddcaae3537d06c 100644 (file)
@@ -743,6 +743,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1504,
 /**/
     1503,
 /**/