]> granicus.if.org Git - vim/commitdiff
patch 8.2.3321: some code is not tested v8.2.3321
authorDominique Pelle <dominique.pelle@gmail.com>
Mon, 9 Aug 2021 19:04:44 +0000 (21:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 9 Aug 2021 19:04:44 +0000 (21:04 +0200)
Problem:    Some code is not tested.
Solution:   Add some more tests. (Dominique PellĂ©, closes #8735)

src/testdir/test_excmd.vim
src/testdir/test_writefile.vim
src/version.c

index 514a4cfb763ad5ded7233849cc648d1fe9b62fca..b080575e4026fe26065430c946ebbde270ceeddd 100644 (file)
@@ -382,6 +382,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 :print command
 func Test_print_cmd()
   call assert_fails('print', 'E749:')
index 9200f2b4b8dcc77fd7e3da255384a75b7932896e..a8204ef02d12e1271f1cabc93bca59651a7d46b4 100644 (file)
@@ -230,6 +230,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()
index 43ff1568a3d1bbc2a4957d33b94f89390ff37f45..ffe37a46025d7fe957a564697716da3f2e8cac84 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3321,
 /**/
     3320,
 /**/