diff src/testdir/test_timers.vim @ 17159:3fd0765f454f v8.1.1579

patch 8.1.1579: dict and list could be GC'ed while displaying error commit https://github.com/vim/vim/commit/adc6714aac20f5462a0ecec50ab4806b2f3ab0db Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 22 01:40:42 2019 +0200 patch 8.1.1579: dict and list could be GC'ed while displaying error Problem: Dict and list could be GC'ed while displaying error in a timer. (Yasuhiro Matsumoto) Solution: Block garbage collection when executing a timer. Add test_garbagecollect_soon(). Add "no_wait_return" to test_override(). (closes #4571)
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Jun 2019 01:45:05 +0200
parents 8e9e9124c7a2
children 7927cf327396
line wrap: on
line diff
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -309,4 +309,28 @@ func Test_restore_count()
   call delete('Xtrctext')
 endfunc
 
+" Test that the garbage collector isn't triggered if a timer callback invokes
+" vgetc().
+func Test_nocatch_garbage_collect()
+  " 'uptimetime. must be bigger than the timer timeout
+  set ut=200
+  call test_garbagecollect_soon()
+  call test_override('no_wait_return', 0)
+  func CauseAnError(id)
+    " This will show an error and wait for Enter.
+    let a = {'foo', 'bar'}
+  endfunc
+  func FeedChar(id)
+    call feedkeys('x', 't')
+  endfunc
+  call timer_start(300, 'FeedChar')
+  call timer_start(100, 'CauseAnError')
+  let x = getchar()
+
+  set ut&
+  call test_override('no_wait_return', 1)
+  delfunc CauseAnError
+  delfunc FeedChar
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab