patch 8.1.0837: timer interrupting cursorhold and mapping not tested

Problem:    Timer interrupting cursorhold and mapping not tested.
Solution:   Add tests with timers. (Ozaki Kiichi, closes #3871)
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 0eabc2e..c502a26 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -32,6 +32,28 @@
     call timer_start(100, 'ExitInsertMode')
     call feedkeys('a', 'x!')
     call assert_equal(1, g:triggered)
+    unlet g:triggered
+    au! CursorHoldI
+    set updatetime&
+  endfunc
+
+  func Test_cursorhold_insert_with_timer_interrupt()
+    if !has('job')
+      return
+    endif
+    " Need to move the cursor.
+    call feedkeys("ggG", "xt")
+
+    " Confirm the timer invoked in exit_cb of the job doesn't disturb
+    " CursorHoldI event.
+    let g:triggered = 0
+    au CursorHoldI * let g:triggered += 1
+    set updatetime=500
+    call job_start(has('win32') ? 'cmd /c echo:' : 'echo',
+          \ {'exit_cb': {j, s -> timer_start(1000, 'ExitInsertMode')}})
+    call feedkeys('a', 'x!')
+    call assert_equal(1, g:triggered)
+    unlet g:triggered
     au! CursorHoldI
     set updatetime&
   endfunc
@@ -44,6 +66,7 @@
     " CursorHoldI does not trigger after CTRL-X
     call feedkeys("a\<C-X>", 'x!')
     call assert_equal(0, g:triggered)
+    unlet g:triggered
     au! CursorHoldI
     set updatetime&
   endfunc
@@ -452,7 +475,7 @@
 endfunc
 
 func Test_OptionSet()
-  if !has("eval") || !has("autocmd") || !exists("+autochdir")
+  if !has("eval") || !exists("+autochdir")
     return
   endif
 
@@ -595,7 +618,7 @@
 
 func Test_OptionSet_diffmode()
   call test_override('starting', 1)
-  " 18: Changing an option when enetering diff mode
+  " 18: Changing an option when entering diff mode
   new
   au OptionSet diff :let &l:cul=v:option_new