patch 8.2.0275: some Ex code not covered by tests
Problem: Some Ex code not covered by tests.
Solution: Add test cases. (Yegappan Lakshmanan, closes #5659)
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index 2407f8e..472945d 100644
--- a/src/testdir/test_excmd.vim
+++ b/src/testdir/test_excmd.vim
@@ -238,6 +238,22 @@
call assert_equal(['foo4'], readfile('foo'))
call assert_equal(['bar2'], readfile('bar'))
+ " Test for closing a window with a modified buffer
+ let buf = RunVimInTerminal('', {'rows': 20})
+ call term_sendkeys(buf, ":set nomore\n")
+ call term_sendkeys(buf, ":new\n")
+ call term_sendkeys(buf, ":call setline(1, 'abc')\n")
+ call term_sendkeys(buf, ":confirm close\n")
+ call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
+ \ term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, "C")
+ call term_sendkeys(buf, ":confirm close\n")
+ call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$',
+ \ term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, "N")
+ call term_sendkeys(buf, ":quit\n")
+ call StopVimInTerminal(buf)
+
call delete('foo')
call delete('bar')
endfunc