view src/testdir/test_interrupt.vim @ 33233:108d890d887f v9.0.1890

patch 9.0.1890: Vim9: lookup code for class/object repaeated Commit: https://github.com/vim/vim/commit/f36bbcd402c6ee5a27bcab3b20b6362ab93b8898 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Sep 10 18:19:06 2023 +0200 patch 9.0.1890: Vim9: lookup code for class/object repaeated Problem: Vim9: lookup code for class/object repaeated Solution: Refactor and make use of lookup functions closes: #13067 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Sep 2023 18:30:04 +0200
parents 860f148e7a64
children
line wrap: on
line source

" Test behavior of interrupt()

let s:bufwritepre_called = 0
let s:bufwritepost_called = 0

func s:bufwritepre()
  let s:bufwritepre_called = 1
  call interrupt()
endfunction

func s:bufwritepost()
  let s:bufwritepost_called = 1
endfunction

func Test_interrupt()
  new Xinterrupt
  let n = 0
  try
    au BufWritePre Xinterrupt call s:bufwritepre()
    au BufWritePost Xinterrupt call s:bufwritepost()
    w!
  catch /^Vim:Interrupt$/
  endtry
  call assert_equal(1, s:bufwritepre_called)
  call assert_equal(0, s:bufwritepost_called)
  call assert_equal(0, filereadable('Xinterrupt'))

  au! BufWritePre
  au! BufWritePost
endfunc

" vim: shiftwidth=2 sts=2 expandtab