aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-08-13 18:20:09 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-09-17 02:10:43 +0100
commit2cbbab28d2854cc226ee90be0e9d2527cf53644d (patch)
tree81f7d01ac8587e8c55830a33aef8d059e183fc87
parente9ddff9d8a86e5e66ebbf7a37c5ae273c9471ccd (diff)
downloadrneovim-2cbbab28d2854cc226ee90be0e9d2527cf53644d.tar.gz
rneovim-2cbbab28d2854cc226ee90be0e9d2527cf53644d.tar.bz2
rneovim-2cbbab28d2854cc226ee90be0e9d2527cf53644d.zip
vim-patch:8.2.3321: some code is not tested
Problem: Some code is not tested. Solution: Add some more tests. (Dominique Pellé, closes vim/vim#8735) https://github.com/vim/vim/commit/bd9e7961256ea6a98bd5a7bfe14e32c4c47186e6 Include Test_confirm_write_partial_file() anyway, even though it will not be run.
-rw-r--r--src/nvim/testdir/test_excmd.vim36
-rw-r--r--src/nvim/testdir/test_writefile.vim8
2 files changed, 44 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim
index ed2bb2c06b..2d01cbba83 100644
--- a/src/nvim/testdir/test_excmd.vim
+++ b/src/nvim/testdir/test_excmd.vim
@@ -313,6 +313,42 @@ func Test_confirm_write_ro()
call delete('Xconfirm_write_ro')
endfunc
+func Test_confirm_write_partial_file()
+ CheckNotGui
+ CheckRunVimInTerminal
+
+ call writefile(['a', 'b', 'c', 'd'], 'Xwrite_partial')
+ call writefile(['set nobackup ff=unix cmdheight=2',
+ \ 'edit Xwrite_partial'], 'Xscript')
+ let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
+
+ call term_sendkeys(buf, ":confirm 2,3w\n")
+ call WaitForAssert({-> assert_match('^Write partial file? *$',
+ \ term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$',
+ \ term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, 'N')
+ call WaitForAssert({-> assert_match('.* All$', term_getline(buf, 20))}, 1000)
+ call assert_equal(['a', 'b', 'c', 'd'], readfile('Xwrite_partial'))
+ call delete('Xwrite_partial')
+
+ call term_sendkeys(buf, ":confirm 2,3w\n")
+ call WaitForAssert({-> assert_match('^Write partial file? *$',
+ \ term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$',
+ \ term_getline(buf, 20))}, 1000)
+ call term_sendkeys(buf, 'Y')
+ call WaitForAssert({-> assert_match('^"Xwrite_partial" \[New\] 2L, 4B written *$',
+ \ term_getline(buf, 19))}, 1000)
+ call WaitForAssert({-> assert_match('^Press ENTER or type command to continue *$',
+ \ term_getline(buf, 20))}, 1000)
+ call assert_equal(['b', 'c'], readfile('Xwrite_partial'))
+
+ call StopVimInTerminal(buf)
+ call delete('Xwrite_partial')
+ call delete('Xscript')
+endfunc
+
" Test for the :winsize command
func Test_winsize_cmd()
call assert_fails('winsize 1', 'E465:')
diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim
index 2504fcb14e..aa7882d129 100644
--- a/src/nvim/testdir/test_writefile.vim
+++ b/src/nvim/testdir/test_writefile.vim
@@ -191,6 +191,14 @@ func Test_saveas()
close!
enew | only
call delete('Xfile')
+
+ " :saveas should detect and set the file type.
+ syntax on
+ saveas! Xsaveas.pl
+ call assert_equal('perl', &filetype)
+ syntax off
+ %bw!
+ call delete('Xsaveas.pl')
endfunc
func Test_write_errors()