vim-patch:8.2.2873: not enough tests for writing buffers

Problem:    Not enough tests for writing buffers.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#8229)

46aa6f93ac

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq 2022-11-07 07:21:46 +08:00
parent bdf87efeb5
commit 7e1d9c560b
4 changed files with 62 additions and 2 deletions

View File

@ -434,4 +434,24 @@ func Test_buf_pattern_invalid()
bwipe! bwipe!
endfunc endfunc
" Test for the 'maxmem' and 'maxmemtot' options
func Test_buffer_maxmem()
" use 1KB per buffer and 2KB for all the buffers
" set maxmem=1 maxmemtot=2
new
let v:errmsg = ''
" try opening some files
edit test_arglist.vim
call assert_equal('test_arglist.vim', bufname())
edit test_eval_stuff.vim
call assert_equal('test_eval_stuff.vim', bufname())
b test_arglist.vim
call assert_equal('test_arglist.vim', bufname())
b test_eval_stuff.vim
call assert_equal('test_eval_stuff.vim', bufname())
close
call assert_equal('', v:errmsg)
" set maxmem& maxmemtot&
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -1513,6 +1513,7 @@ func Test_cmdline_expand_special()
call assert_fails('e <afile>', 'E495:') call assert_fails('e <afile>', 'E495:')
call assert_fails('e <abuf>', 'E496:') call assert_fails('e <abuf>', 'E496:')
call assert_fails('e <amatch>', 'E497:') call assert_fails('e <amatch>', 'E497:')
call writefile([], 'Xfile.cpp') call writefile([], 'Xfile.cpp')
call writefile([], 'Xfile.java') call writefile([], 'Xfile.java')
new Xfile.cpp new Xfile.cpp
@ -2006,6 +2007,26 @@ func Test_recalling_cmdline()
cunmap <Plug>(save-cmdline) cunmap <Plug>(save-cmdline)
endfunc endfunc
" Test for the 'suffixes' option
func Test_suffixes_opt()
call writefile([], 'Xfile')
call writefile([], 'Xfile.c')
call writefile([], 'Xfile.o')
set suffixes=
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile Xfile.c Xfile.o', @:)
set suffixes=.c
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile Xfile.o Xfile.c', @:)
set suffixes=,,
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xfile.c Xfile.o Xfile', @:)
set suffixes&
call delete('Xfile')
call delete('Xfile.c')
call delete('Xfile.o')
endfunc
" Test for using a popup menu for the command line completion matches " Test for using a popup menu for the command line completion matches
" (wildoptions=pum) " (wildoptions=pum)
func Test_wildmenu_pum() func Test_wildmenu_pum()

View File

@ -2454,6 +2454,7 @@ endfunc
func Test_glob() func Test_glob()
call assert_equal('', glob(v:_null_string)) call assert_equal('', glob(v:_null_string))
call assert_equal('', globpath(v:_null_string, v:_null_string)) call assert_equal('', globpath(v:_null_string, v:_null_string))
call assert_fails("let x = globpath(&rtp, 'syntax/c.vim', [])", 'E745:')
call writefile([], 'Xglob1') call writefile([], 'Xglob1')
call writefile([], 'XGLOB2') call writefile([], 'XGLOB2')

View File

@ -484,7 +484,7 @@ func Test_write_readonly_dir()
" Root can do it too. " Root can do it too.
CheckNotRoot CheckNotRoot
call mkdir('Xdir') call mkdir('Xdir/')
call writefile(['one'], 'Xdir/Xfile1') call writefile(['one'], 'Xdir/Xfile1')
call setfperm('Xdir', 'r-xr--r--') call setfperm('Xdir', 'r-xr--r--')
" try to create a new file in the directory " try to create a new file in the directory
@ -768,7 +768,7 @@ func Test_read_write_bin()
call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B')) call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B'))
call delete('XNoEolSetEol') call delete('XNoEolSetEol')
set ff& set ff& fixeol&
bwipe! XNoEolSetEol bwipe! XNoEolSetEol
endfunc endfunc
@ -911,6 +911,24 @@ func Test_write_backup_symlink()
call delete('Xfile.bak') call delete('Xfile.bak')
endfunc endfunc
" Test for ':write ++bin' and ':write ++nobin'
func Test_write_binary_file()
" create a file without an eol/eof character
call writefile(0z616161, 'Xfile1', 'b')
new Xfile1
write ++bin Xfile2
write ++nobin Xfile3
call assert_equal(0z616161, readblob('Xfile2'))
if has('win32')
call assert_equal(0z6161610D.0A, readblob('Xfile3'))
else
call assert_equal(0z6161610A, readblob('Xfile3'))
endif
call delete('Xfile1')
call delete('Xfile2')
call delete('Xfile3')
endfunc
" Check that buffer is written before triggering QuitPre " Check that buffer is written before triggering QuitPre
func Test_wq_quitpre_autocommand() func Test_wq_quitpre_autocommand()
edit Xsomefile edit Xsomefile