func Test_window_cmd_wincmd_gf()
let fname = 'test_gf.txt'
let swp_fname = '.' . fname . '.swp'
- call writefile([], fname)
- call writefile([], swp_fname)
+ call writefile([], fname, 'D')
+ call writefile([], swp_fname, 'D')
function s:swap_exists()
let v:swapchoice = s:swap_choice
endfunc
call assert_notequal(fname, bufname("%"))
new | only!
- call delete(fname)
- call delete(swp_fname)
augroup! test_window_cmd_wincmd_gf
endfunc
CheckUnix
set hidden autoread
- call writefile(['2'], 'tmp.txt')
+ call writefile(['2'], 'tmp.txt', 'D')
new tmp.txt
q
call Fun_RenewFile()
wincmd p
" reset
q
- call delete('tmp.txt')
set hidden&vim autoread&vim
delfunc Fun_RenewFile
endfunc
endtry
endwhile
- call writefile(['first', 'second', 'third'], 'Xnorfile1')
- call writefile([], 'Xnorfile2')
- call writefile([], 'Xnorfile3')
+ call writefile(['first', 'second', 'third'], 'Xnorfile1', 'D')
+ call writefile([], 'Xnorfile2', 'D')
+ call writefile([], 'Xnorfile3', 'D')
" Argument list related commands
args Xnorfile1 Xnorfile2 Xnorfile3
endif
%bwipe!
- call delete('Xnorfile1')
- call delete('Xnorfile2')
- call delete('Xnorfile3')
only
endfunc
func Test_writefile()
let f = tempname()
- call writefile(["over","written"], f, "b")
- call writefile(["hello","world"], f, "b")
+ call writefile(["over", "written"], f, "bD")
+ call writefile(["hello", "world"], f, "b")
call writefile(["!", "good"], f, "a")
call writefile(["morning"], f, "ab")
call writefile(["", "vimmers"], f, "ab")
call assert_equal("good", l[2])
call assert_equal("morning", l[3])
call assert_equal("vimmers", l[4])
- call delete(f)
call assert_fails('call writefile("text", "Xwffile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob')
endfunc
set nobackup nowritebackup backupdir=. backupskip=
new
let contents = ["line one", "line two"]
- call writefile(contents, 'Xwfcfile')
+ call writefile(contents, 'Xwfcfile', 'D')
edit Xwfcfile
call setline(1, ["first line", "cannot convert \u010b", "third line"])
call assert_fails('write ++enc=cp932', 'E513:')
call delete('Xwfcfily~')
%bw!
- call delete('Xwfcfile')
call delete('Xwfcfile' .. &backupext)
bwipe!
set backup& writebackup& backupdir&vim backupskip&vim
" but then the backup file must remain
set nobackup writebackup backupdir=. backupskip=
let contents = ["line one", "line two"]
- call writefile(contents, 'Xwf2file_conversion_err')
+ call writefile(contents, 'Xwf2file_conversion_err', 'D')
edit Xwf2file_conversion_err
call setline(1, ["first line", "cannot convert \u010b", "third line"])
set fileencoding=latin1
call assert_match('CONVERSION ERROR', output)
call assert_equal(contents, readfile('Xwf2file_conversion_err~'))
- call delete('Xwf2file_conversion_err')
call delete('Xwf2file_conversion_err~')
bwipe!
set backup& writebackup& backupdir&vim backupskip&vim
func Test_writefile_sync_arg()
" This doesn't check if fsync() works, only that the argument is accepted.
- call writefile(['one'], 'Xtest', 's')
+ call writefile(['one'], 'Xtest', 'sD')
call writefile(['two'], 'Xtest', 'S')
- call delete('Xtest')
endfunc
func Test_writefile_sync_dev_stdout()
CheckRunVimInTerminal
" First read the file into a buffer
- call writefile(["Line1", "Line2"], 'Xwfmfile')
+ call writefile(["Line1", "Line2"], 'Xwfmfile', 'D')
let old_ftime = getftime('Xwfmfile')
let buf = RunVimInTerminal('Xwfmfile', #{rows : 10})
call TermWait(buf)
" clean up
call StopVimInTerminal(buf)
- call delete('Xwfmfile')
endfunc
" Test for an autocmd unloading a buffer during a write command
" Test for writing to a readonly file
func Test_write_readonly()
- call writefile([], 'Xwrofile')
+ call writefile([], 'Xwrofile', 'D')
call setfperm('Xwrofile', "r--------")
edit Xwrofile
set noreadonly backupskip=
set autowriteall&
set backupskip&
- call delete('Xwrofile')
%bw!
endfunc
" Test for 'patchmode'
func Test_patchmode()
- call writefile(['one'], 'Xpafile')
+ call writefile(['one'], 'Xpafile', 'D')
set patchmode=.orig nobackup backupskip= writebackup
new Xpafile
call setline(1, 'two')
call assert_equal([], readfile('Xpafile.orig'))
set patchmode& backup& backupskip& writebackup&
- call delete('Xpafile')
call delete('Xpafile.orig')
endfunc
" Root can do it too.
CheckNotRoot
- call mkdir('Xrodir/')
+ call mkdir('Xrodir/', 'R')
call writefile(['one'], 'Xrodir/Xfile1')
call setfperm('Xrodir', 'r-xr--r--')
" try to create a new file in the directory
set patchmode=.orig
call assert_fails('write', 'E509:')
call setfperm('Xrodir', 'rwxr--r--')
- call delete('Xrodir', 'rf')
set backupdir& backupskip& patchmode&
endfunc
2 cp1251 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01
3 cp866 text: \84«ï Vim version 6.2. \8f®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01
END
- call writefile(text, 'Xwfefile')
+ call writefile(text, 'Xwfefile', 'D')
edit Xwfefile
" write tests:
END
call assert_equal(expected, readfile('Xwfetest'))
- call delete('Xwfefile')
call delete('Xwfetest')
call delete('Xutf8')
call delete('Xcp1251')
set cpoptions+=S
" Check that editing a latin1 file doesn't see a BOM
- call writefile(["\xFE\xFElatin-1"], 'Xrwtest1')
+ call writefile(["\xFE\xFElatin-1"], 'Xrwtest1', 'D')
edit Xrwtest1
call assert_equal('latin1', &fileencoding)
call assert_equal(0, &bomb)
set cpoptions-=S
let &fileencoding = save_fileencoding
- call delete('Xrwtest1')
call delete('Xrwfile2')
call delete('Xrwtest3')
%bw!
func Test_read_write_bin()
" write file missing EOL
- call writefile(['noeol'], "XNoEolSetEol", 'bS')
+ call writefile(['noeol'], "XNoEolSetEol", 'bSD')
call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B'))
" when file is read 'eol' is off
w
call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B'))
- call delete('XNoEolSetEol')
set ff& fixeol&
bwipe! XNoEolSetEol
endfunc
call mkdir('Xbackup')
let save_backupdir = &backupdir
set backupdir=.,./Xbackup
- call writefile(['1111'], 'Xwbsfile')
+ call writefile(['1111'], 'Xwbsfile', 'D')
silent !ln -s Xwbsfile Xwbsfile.bak
new Xwbsfile
set backup& backupcopy& backupext&
%bw
- call delete('Xwbsfile')
call delete('Xwbsfile.bak')
call delete('Xbackup', 'rf')
let &backupdir = save_backupdir
" Test for ':write ++bin' and ':write ++nobin'
func Test_write_binary_file()
" create a file without an eol/eof character
- call writefile(0z616161, 'Xwbfile1', 'b')
+ call writefile(0z616161, 'Xwbfile1', 'bD')
new Xwbfile1
write ++bin Xwbfile2
write ++nobin Xwbfile3
else
call assert_equal(0z6161610A, readblob('Xwbfile3'))
endif
- call delete('Xwbfile1')
call delete('Xwbfile2')
call delete('Xwbfile3')
endfunc
func Test_xxd_patch()
let cmd1 = 'silent !' .. s:xxd_cmd .. ' -r Xxxdin Xxxdfile'
let cmd2 = 'silent !' .. s:xxd_cmd .. ' -g1 Xxxdfile > Xxxdout'
- call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin')
- call writefile(['::::::::'], 'Xxxdfile')
+ call writefile(["2: 41 41", "8: 42 42"], 'Xxxdin', 'D')
+ call writefile(['::::::::'], 'Xxxdfile', 'D')
exe cmd1
exe cmd2
call assert_equal(['00000000: 3a 3a 41 41 3a 3a 3a 3a 42 42 ::AA::::BB'], readfile('Xxxdout'))
exe cmd2
call assert_equal(['00000000: 3a 3a 45 45 3a 3a 3a 3a 42 44 46 46 ::EE::::BDFF'], readfile('Xxxdout'))
- call delete('Xxxdin')
- call delete('Xxxdfile')
call delete('Xxxdout')
endfunc
" -c0 selects the format specific default column value, as if no -c was given
" except for -ps, where it disables extra newlines
func Test_xxd_c0_is_def_cols()
- call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin')
+ call writefile(["abcdefghijklmnopqrstuvwxyz0123456789"], 'Xxdin', 'D')
for cols in ['-c0', '-c 0', '-cols 0']
for fmt in ['', '-b', '-e', '-i']
exe 'r! ' . s:xxd_cmd . ' ' . fmt ' Xxdin > Xxdout1'
call assert_equalfile('Xxdout1', 'Xxdout2')
endfor
endfor
- call delete('Xxdin')
call delete('Xxdout1')
call delete('Xxdout2')
endfunc
\ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
\ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
\ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"],
- \ 'Xxdin')
+ \ 'Xxdin', 'D')
for cols in ['-c0', '-c 0', '-cols 0']
exe 'r! ' . s:xxd_cmd . ' -ps ' . cols ' Xxdin'
" output seems to start in line 2
" xxd output must be non-empty and comprise only lower case hex digits
call assert_match("^[0-9a-f][0-9a-f]*$", out)
endfor
- call delete('Xxdin')
endfunc
" vim: shiftwidth=2 sts=2 expandtab