summaryrefslogtreecommitdiff
path: root/src/testdir/test_swap.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-02-22 21:21:27 +0100
committerBram Moolenaar <Bram@vim.org>2020-02-22 21:21:27 +0100
commitb654103ad1e379348616f354272db86804ab4bdb (patch)
treec4013f54909d37390b42b5ed70006ad8600f0dd3 /src/testdir/test_swap.vim
parentb4d2cb1083974a7a7262417d09baf474ca816452 (diff)
downloadvim-git-b654103ad1e379348616f354272db86804ab4bdb.tar.gz
patch 8.2.0301: insufficient testing for exception handlingv8.2.0301
Problem: Insufficient testing for exception handling and the "attention" prompt. Solution: Add test cases. (Yegappan Lakshmanan, closes #5681)
Diffstat (limited to 'src/testdir/test_swap.vim')
-rw-r--r--src/testdir/test_swap.vim26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/testdir/test_swap.vim b/src/testdir/test_swap.vim
index 7ce35ccae..cc452c3a7 100644
--- a/src/testdir/test_swap.vim
+++ b/src/testdir/test_swap.vim
@@ -1,6 +1,7 @@
" Tests for the swap feature
source shared.vim
+source term_util.vim
func s:swapname()
return trim(execute('swapname'))
@@ -349,4 +350,29 @@ func Test_swap_split_win()
augroup! test_swap_splitwin
endfunc
+" Test for selecting 'q' in the attention prompt
+func Test_swap_prompt_splitwin()
+ if !CanRunVimInTerminal()
+ throw 'Skipped: cannot run vim in terminal'
+ endif
+ call writefile(['foo bar'], 'Xfile1')
+ edit Xfile1
+ let buf = RunVimInTerminal('', {'rows': 20})
+ call term_sendkeys(buf, ":set nomore\n")
+ call term_sendkeys(buf, ":set noruler\n")
+ call term_sendkeys(buf, ":split Xfile1\n")
+ call term_wait(buf)
+ call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: $', term_getline(buf, 20))})
+ call term_sendkeys(buf, "q")
+ call term_wait(buf)
+ call term_sendkeys(buf, ":")
+ call WaitForAssert({-> assert_match('^:$', term_getline(buf, 20))})
+ call term_sendkeys(buf, "echomsg winnr('$')\<CR>")
+ call term_wait(buf)
+ call WaitForAssert({-> assert_match('^1$', term_getline(buf, 20))})
+ call StopVimInTerminal(buf)
+ %bwipe!
+ call delete('Xfile1')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab