]> granicus.if.org Git - vim/commitdiff
patch 8.2.1260: there is no good test for CursorHold v8.2.1260
authorBram Moolenaar <Bram@vim.org>
Tue, 21 Jul 2020 17:44:47 +0000 (19:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 21 Jul 2020 17:44:47 +0000 (19:44 +0200)
Problem:    There is no good test for CursorHold.
Solution:   Add a test.  Remove duplicated test. (Yegappan Lakshmanan,
            closes #6503

src/testdir/test_autocmd.vim
src/testdir/test_buffer.vim
src/testdir/test_normal.vim
src/version.c

index c167ed951b537dc64c643df6449046f33e292314..70fbe01c0fc008678072d38f3b5ae58bfc939a7c 100644 (file)
@@ -19,6 +19,35 @@ func Test_vim_did_enter()
   " becomes one.
 endfunc
 
+" Test for the CursorHold autocmd
+func Test_CursorHold_autocmd()
+  CheckRunVimInTerminal
+  call writefile(['one', 'two', 'three'], 'Xfile')
+  let before =<< trim END
+    set updatetime=10
+    au CursorHold * call writefile([line('.')], 'Xoutput', 'a')
+  END
+  call writefile(before, 'Xinit')
+  let buf = RunVimInTerminal('-S Xinit Xfile', {})
+  call term_wait(buf)
+  call term_sendkeys(buf, "gg")
+  call term_wait(buf)
+  sleep 50m
+  call term_sendkeys(buf, "j")
+  call term_wait(buf)
+  sleep 50m
+  call term_sendkeys(buf, "j")
+  call term_wait(buf)
+  sleep 50m
+  call StopVimInTerminal(buf)
+
+  call assert_equal(['1', '2', '3'], readfile('Xoutput')[-3:-1])
+
+  call delete('Xinit')
+  call delete('Xoutput')
+  call delete('Xfile')
+endfunc
+
 if has('timers')
 
   func ExitInsertMode(id)
index c8f6c5a69625acfdad25518851502a0b00eca4f3..e54b6338cb8e9b8a61fb0490c38311534cf10ffd 100644 (file)
@@ -67,15 +67,6 @@ func Test_bunload_with_offset()
   call assert_fails('1,4bunload', 'E16:')
   call assert_fails(',100bunload', 'E16:')
 
-  " Use a try-catch for this test. When assert_fails() is used for this
-  " test, the command fails with E515: instead of E90:
-  let caught_E90 = 0
-  try
-    $bunload
-  catch /E90:/
-    let caught_E90 = 1
-  endtry
-  call assert_equal(1, caught_E90)
   call assert_fails('$bunload', 'E90:')
 endfunc
 
index 68aae534eb922901752fa8dfee75f767b20b5dff..58c9ece68ca71dde8890a8d4e94dff9531a79aea 100644 (file)
@@ -2506,24 +2506,6 @@ func Test_normal47_visual_buf_wipe()
   set nomodified
 endfunc
 
-func Test_normal47_autocmd()
-  " disabled, does not seem to be possible currently
-  throw "Skipped: not possible to test cursorhold autocmd while waiting for input in normal_cmd"
-  new
-  call append(0, repeat('-',20))
-  au CursorHold * call feedkeys('2l', '')
-  1
-  set updatetime=20
-  " should delete 12 chars (d12l)
-  call feedkeys('d1', '!')
-  call assert_equal('--------', getline(1))
-
-  " clean up
-  au! CursorHold
-  set updatetime=4000
-  bw!
-endfunc
-
 func Test_normal48_wincmd()
   new
   exe "norm! \<c-w>c"
index 528c8c0aaf2a680494432de13e7f3dd64628f908..8df1359255cd6c2dd76864c6fa1244a8cbfb732a 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1260,
 /**/
     1259,
 /**/