Skip to content

Commit bd9e796

Browse files
dpellebrammool
authored andcommitted
patch 8.2.3321: some code is not tested
Problem: Some code is not tested. Solution: Add some more tests. (Dominique Pellé, closes #8735)
1 parent 8ee52af commit bd9e796

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

src/testdir/test_excmd.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,42 @@ func Test_confirm_write_ro()
382382
call delete('Xconfirm_write_ro')
383383
endfunc
384384

385+
func Test_confirm_write_partial_file()
386+
CheckNotGui
387+
CheckRunVimInTerminal
388+
389+
call writefile(['a', 'b', 'c', 'd'], 'Xwrite_partial')
390+
call writefile(['set nobackup ff=unix cmdheight=2',
391+
\ 'edit Xwrite_partial'], 'Xscript')
392+
let buf = RunVimInTerminal('-S Xscript', {'rows': 20})
393+
394+
call term_sendkeys(buf, ":confirm 2,3w\n")
395+
call WaitForAssert({-> assert_match('^Write partial file? *$',
396+
\ term_getline(buf, 19))}, 1000)
397+
call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$',
398+
\ term_getline(buf, 20))}, 1000)
399+
call term_sendkeys(buf, 'N')
400+
call WaitForAssert({-> assert_match('.* All$', term_getline(buf, 20))}, 1000)
401+
call assert_equal(['a', 'b', 'c', 'd'], readfile('Xwrite_partial'))
402+
call delete('Xwrite_partial')
403+
404+
call term_sendkeys(buf, ":confirm 2,3w\n")
405+
call WaitForAssert({-> assert_match('^Write partial file? *$',
406+
\ term_getline(buf, 19))}, 1000)
407+
call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$',
408+
\ term_getline(buf, 20))}, 1000)
409+
call term_sendkeys(buf, 'Y')
410+
call WaitForAssert({-> assert_match('^"Xwrite_partial" \[New\] 2L, 4B written *$',
411+
\ term_getline(buf, 19))}, 1000)
412+
call WaitForAssert({-> assert_match('^Press ENTER or type command to continue *$',
413+
\ term_getline(buf, 20))}, 1000)
414+
call assert_equal(['b', 'c'], readfile('Xwrite_partial'))
415+
416+
call StopVimInTerminal(buf)
417+
call delete('Xwrite_partial')
418+
call delete('Xscript')
419+
endfunc
420+
385421
" Test for the :print command
386422
func Test_print_cmd()
387423
call assert_fails('print', 'E749:')

src/testdir/test_writefile.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ func Test_saveas()
230230
close!
231231
enew | only
232232
call delete('Xfile')
233+
234+
" :saveas should detect and set the file type.
235+
syntax on
236+
saveas! Xsaveas.pl
237+
call assert_equal('perl', &filetype)
238+
syntax off
239+
%bw!
240+
call delete('Xsaveas.pl')
233241
endfunc
234242

235243
func Test_write_errors()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3321,
758760
/**/
759761
3320,
760762
/**/

0 commit comments

Comments
 (0)