0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.0611: tests delete files with a separate delete() call

Problem:    Tests delete files with a separate delete() call.
Solution:   Use deferred delete.
This commit is contained in:
Bram Moolenaar
2022-09-27 19:34:35 +01:00
parent 859ea4bc76
commit 70e672580b
10 changed files with 70 additions and 135 deletions

View File

@@ -1,26 +1,25 @@
" Test getting and setting file permissions. " Test getting and setting file permissions.
func Test_file_perm() func Test_file_perm()
call assert_equal('', getfperm('Xtest')) call assert_equal('', getfperm('XtestPerm'))
call assert_equal(0, 'Xtest'->setfperm('r--------')) call assert_equal(0, 'XtestPerm'->setfperm('r--------'))
call writefile(['one'], 'Xtest') call writefile(['one'], 'XtestPerm', 'D')
call assert_true(len('Xtest'->getfperm()) == 9) call assert_true(len('XtestPerm'->getfperm()) == 9)
call assert_equal(1, setfperm('Xtest', 'rwx------')) call assert_equal(1, setfperm('XtestPerm', 'rwx------'))
if has('win32') if has('win32')
call assert_equal('rw-rw-rw-', getfperm('Xtest')) call assert_equal('rw-rw-rw-', getfperm('XtestPerm'))
else else
call assert_equal('rwx------', getfperm('Xtest')) call assert_equal('rwx------', getfperm('XtestPerm'))
endif endif
call assert_equal(1, setfperm('Xtest', 'r--r--r--')) call assert_equal(1, setfperm('XtestPerm', 'r--r--r--'))
call assert_equal('r--r--r--', getfperm('Xtest')) call assert_equal('r--r--r--', getfperm('XtestPerm'))
call assert_fails("setfperm('Xtest', '---')") call assert_fails("setfperm('XtestPerm', '---')")
call assert_equal(1, setfperm('Xtest', 'rwx------')) call assert_equal(1, setfperm('XtestPerm', 'rwx------'))
call delete('Xtest')
call assert_fails("call setfperm(['Xpermfile'], 'rw-rw-rw-')", 'E730:') call assert_fails("call setfperm(['Xpermfile'], 'rw-rw-rw-')", 'E730:')
call assert_fails("call setfperm('Xpermfile', [])", 'E730:') call assert_fails("call setfperm('Xpermfile', [])", 'E730:')

View File

@@ -105,7 +105,7 @@ func Test_FileChangedShell_edit()
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'reload' au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'reload'
augroup END augroup END
call assert_equal(&fileformat, 'unix') call assert_equal(&fileformat, 'unix')
call writefile(["line1\r", "line2\r"], 'Xchanged_r') call writefile(["line1\r", "line2\r"], 'Xchanged_r', 'D')
let g:reason = '' let g:reason = ''
checktime checktime
call assert_equal('changed', g:reason) call assert_equal('changed', g:reason)
@@ -134,7 +134,6 @@ func Test_FileChangedShell_edit()
au! testreload au! testreload
bwipe! bwipe!
call delete(undofile('Xchanged_r')) call delete(undofile('Xchanged_r'))
call delete('Xchanged_r')
endfunc endfunc
func Test_FileChangedShell_edit_dialog() func Test_FileChangedShell_edit_dialog()
@@ -152,7 +151,7 @@ func Test_FileChangedShell_edit_dialog()
au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask' au FileChangedShell Xchanged_r let g:reason = v:fcs_reason | let v:fcs_choice = 'ask'
augroup END augroup END
call assert_equal(&fileformat, 'unix') call assert_equal(&fileformat, 'unix')
call writefile(["line1\r", "line2\r"], 'Xchanged_r') call writefile(["line1\r", "line2\r"], 'Xchanged_r', 'D')
let g:reason = '' let g:reason = ''
call feedkeys('L', 'L') " load file content only call feedkeys('L', 'L') " load file content only
checktime checktime
@@ -183,7 +182,6 @@ func Test_FileChangedShell_edit_dialog()
au! testreload au! testreload
bwipe! bwipe!
call delete(undofile('Xchanged_r')) call delete(undofile('Xchanged_r'))
call delete('Xchanged_r')
endfunc endfunc
func Test_file_changed_dialog() func Test_file_changed_dialog()
@@ -241,27 +239,26 @@ func Test_file_changed_dialog()
" File created after starting to edit it " File created after starting to edit it
call delete('Xchanged_d') call delete('Xchanged_d')
new Xchanged_d new Xchanged_d
call writefile(['one'], 'Xchanged_d') call writefile(['one'], 'Xchanged_d', 'D')
call feedkeys('L', 'L') call feedkeys('L', 'L')
checktime Xchanged_d checktime Xchanged_d
call assert_equal(['one'], getline(1, '$')) call assert_equal(['one'], getline(1, '$'))
close! close!
bwipe! bwipe!
call delete('Xchanged_d')
endfunc endfunc
" Test for editing a new buffer from a FileChangedShell autocmd " Test for editing a new buffer from a FileChangedShell autocmd
func Test_FileChangedShell_newbuf() func Test_FileChangedShell_newbuf()
call writefile(['one', 'two'], 'Xchfile') call writefile(['one', 'two'], 'Xchfile', 'D')
new Xchfile new Xchfile
augroup testnewbuf augroup testnewbuf
autocmd FileChangedShell * enew autocmd FileChangedShell * enew
augroup END augroup END
call writefile(['red'], 'Xchfile') call writefile(['red'], 'Xchfile')
call assert_fails('checktime', 'E811:') call assert_fails('checktime', 'E811:')
au! testnewbuf au! testnewbuf
call delete('Xchfile')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -22,14 +22,13 @@ endfunc
func Test_fileformat_autocommand() func Test_fileformat_autocommand()
let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""] let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
let ffs = &ffs let ffs = &ffs
call writefile(filecnt, 'Xffafile', 'b') call writefile(filecnt, 'Xffafile', 'bD')
au BufReadPre Xffafile set ffs=dos ff=dos au BufReadPre Xffafile set ffs=dos ff=dos
new Xffafile new Xffafile
call assert_equal('dos', &l:ff) call assert_equal('dos', &l:ff)
call assert_equal('dos', &ffs) call assert_equal('dos', &ffs)
" cleanup " cleanup
call delete('Xffafile')
let &ffs = ffs let &ffs = ffs
au! BufReadPre Xffafile au! BufReadPre Xffafile
bw! bw!
@@ -65,11 +64,11 @@ endfun
" Test for a lot of variations of the 'fileformats' option " Test for a lot of variations of the 'fileformats' option
func Test_fileformats() func Test_fileformats()
" create three test files, one in each format " create three test files, one in each format
call writefile(['unix', 'unix'], 'XXUnix') call writefile(['unix', 'unix'], 'XXUnix', 'D')
call writefile(["dos\r", "dos\r"], 'XXDos') call writefile(["dos\r", "dos\r"], 'XXDos', 'D')
call writefile(["mac\rmac\r"], 'XXMac', 'b') call writefile(["mac\rmac\r"], 'XXMac', 'bD')
" create a file with no End Of Line " create a file with no End Of Line
call writefile(["noeol"], 'XXEol', 'b') call writefile(["noeol"], 'XXEol', 'bD')
" create mixed format files " create mixed format files
call s:concat_files('XXUnix', 'XXDos', 'XXUxDs') call s:concat_files('XXUnix', 'XXDos', 'XXUxDs')
call s:concat_files('XXUnix', 'XXMac', 'XXUxMac') call s:concat_files('XXUnix', 'XXMac', 'XXUxMac')
@@ -277,10 +276,6 @@ func Test_fileformats()
" cleanup " cleanup
only only
%bwipe! %bwipe!
call delete('XXUnix')
call delete('XXDos')
call delete('XXMac')
call delete('XXEol')
call delete('XXUxDs') call delete('XXUxDs')
call delete('XXUxMac') call delete('XXUxMac')
call delete('XXDosMac') call delete('XXDosMac')

View File

@@ -14,7 +14,7 @@ endfunc
func Test_conf_type() func Test_conf_type()
filetype on filetype on
call writefile(['# some comment', 'must be conf'], 'Xconffile') call writefile(['# some comment', 'must be conf'], 'Xconffile', 'D')
augroup filetypedetect augroup filetypedetect
au BufNewFile,BufRead * call assert_equal(0, did_filetype()) au BufNewFile,BufRead * call assert_equal(0, did_filetype())
augroup END augroup END
@@ -22,7 +22,6 @@ func Test_conf_type()
call assert_equal('conf', &filetype) call assert_equal('conf', &filetype)
bwipe! bwipe!
call delete('Xconffile')
filetype off filetype off
endfunc endfunc
@@ -33,12 +32,11 @@ func Test_other_type()
au BufNewFile,BufRead Xotherfile setf testfile au BufNewFile,BufRead Xotherfile setf testfile
au BufNewFile,BufRead * call assert_equal(1, did_filetype()) au BufNewFile,BufRead * call assert_equal(1, did_filetype())
augroup END augroup END
call writefile(['# some comment', 'must be conf'], 'Xotherfile') call writefile(['# some comment', 'must be conf'], 'Xotherfile', 'D')
split Xotherfile split Xotherfile
call assert_equal('testfile', &filetype) call assert_equal('testfile', &filetype)
bwipe! bwipe!
call delete('Xotherfile')
filetype off filetype off
endfunc endfunc
@@ -761,13 +759,12 @@ func Run_script_detection(test_dict)
filetype on filetype on
for [ft, files] in items(a:test_dict) for [ft, files] in items(a:test_dict)
for file in files for file in files
call writefile(file, 'Xtest') call writefile(file, 'Xtest', 'D')
split Xtest split Xtest
call assert_equal(ft, &filetype, 'for text: ' . string(file)) call assert_equal(ft, &filetype, 'for text: ' . string(file))
bwipe! bwipe!
endfor endfor
endfor endfor
call delete('Xtest')
filetype off filetype off
endfunc endfunc
@@ -813,7 +810,7 @@ endfunc
func Test_bas_file() func Test_bas_file()
filetype on filetype on
call writefile(['looks like BASIC'], 'Xfile.bas') call writefile(['looks like BASIC'], 'Xfile.bas', 'D')
split Xfile.bas split Xfile.bas
call assert_equal('basic', &filetype) call assert_equal('basic', &filetype)
bwipe! bwipe!
@@ -867,7 +864,6 @@ func Test_bas_file()
call assert_equal('vb', &filetype) call assert_equal('vb', &filetype)
bwipe! bwipe!
call delete('Xfile.bas')
filetype off filetype off
endfunc endfunc
@@ -876,7 +872,7 @@ func Test_cfg_file()
filetype on filetype on
" *.cfg defaults to cfg " *.cfg defaults to cfg
call writefile(['looks like cfg'], 'cfgfile.cfg') call writefile(['looks like cfg'], 'cfgfile.cfg', 'D')
split cfgfile.cfg split cfgfile.cfg
call assert_equal('cfg', &filetype) call assert_equal('cfg', &filetype)
@@ -905,7 +901,7 @@ endfunc
func Test_d_file() func Test_d_file()
filetype on filetype on
call writefile(['looks like D'], 'Xfile.d') call writefile(['looks like D'], 'Xfile.d', 'D')
split Xfile.d split Xfile.d
call assert_equal('d', &filetype) call assert_equal('d', &filetype)
bwipe! bwipe!
@@ -937,7 +933,6 @@ func Test_d_file()
" clean up " clean up
filetype off filetype off
call delete('Xfile.d')
endfunc endfunc
func Test_dat_file() func Test_dat_file()
@@ -978,7 +973,7 @@ endfunc
func Test_dep3patch_file() func Test_dep3patch_file()
filetype on filetype on
call assert_true(mkdir('debian/patches', 'p')) call assert_true(mkdir('debian/patches', 'pR'))
" series files are not patches " series files are not patches
call writefile(['Description: some awesome patch'], 'debian/patches/series') call writefile(['Description: some awesome patch'], 'debian/patches/series')
@@ -1011,14 +1006,12 @@ func Test_dep3patch_file()
split debian/patches/baz split debian/patches/baz
call assert_notequal('dep3patch', &filetype) call assert_notequal('dep3patch', &filetype)
bwipe! bwipe!
call delete('debian', 'rf')
endfunc endfunc
func Test_dsl_file() func Test_dsl_file()
filetype on filetype on
call writefile([' <!doctype dsssl-spec ['], 'dslfile.dsl') call writefile([' <!doctype dsssl-spec ['], 'dslfile.dsl', 'D')
split dslfile.dsl split dslfile.dsl
call assert_equal('dsl', &filetype) call assert_equal('dsl', &filetype)
bwipe! bwipe!
@@ -1028,14 +1021,13 @@ func Test_dsl_file()
call assert_equal('structurizr', &filetype) call assert_equal('structurizr', &filetype)
bwipe! bwipe!
call delete('dslfile.dsl')
filetype off filetype off
endfunc endfunc
func Test_ex_file() func Test_ex_file()
filetype on filetype on
call writefile(['arbitrary content'], 'Xfile.ex') call writefile(['arbitrary content'], 'Xfile.ex', 'D')
split Xfile.ex split Xfile.ex
call assert_equal('elixir', &filetype) call assert_equal('elixir', &filetype)
bwipe! bwipe!
@@ -1065,31 +1057,30 @@ func Test_ex_file()
call assert_equal('euphoria3', &filetype) call assert_equal('euphoria3', &filetype)
bwipe! bwipe!
call delete('Xfile.ex')
filetype off filetype off
endfunc endfunc
func Test_foam_file() func Test_foam_file()
filetype on filetype on
call assert_true(mkdir('0', 'p')) call assert_true(mkdir('0', 'pR'))
call assert_true(mkdir('0.orig', 'p')) call assert_true(mkdir('0.orig', 'pR'))
call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict') call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict', 'D')
split Xfile1Dict split Xfile1Dict
call assert_equal('foam', &filetype) call assert_equal('foam', &filetype)
bwipe! bwipe!
call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict.something') call writefile(['FoamFile {', ' object something;'], 'Xfile1Dict.something', 'D')
split Xfile1Dict.something split Xfile1Dict.something
call assert_equal('foam', &filetype) call assert_equal('foam', &filetype)
bwipe! bwipe!
call writefile(['FoamFile {', ' object something;'], 'XfileProperties') call writefile(['FoamFile {', ' object something;'], 'XfileProperties', 'D')
split XfileProperties split XfileProperties
call assert_equal('foam', &filetype) call assert_equal('foam', &filetype)
bwipe! bwipe!
call writefile(['FoamFile {', ' object something;'], 'XfileProperties.something') call writefile(['FoamFile {', ' object something;'], 'XfileProperties.something', 'D')
split XfileProperties.something split XfileProperties.something
call assert_equal('foam', &filetype) call assert_equal('foam', &filetype)
bwipe! bwipe!
@@ -1114,19 +1105,13 @@ func Test_foam_file()
call assert_equal('foam', &filetype) call assert_equal('foam', &filetype)
bwipe! bwipe!
call delete('0', 'rf')
call delete('0.orig', 'rf')
call delete('Xfile1Dict')
call delete('Xfile1Dict.something')
call delete('XfileProperties')
call delete('XfileProperties.something')
filetype off filetype off
endfunc endfunc
func Test_frm_file() func Test_frm_file()
filetype on filetype on
call writefile(['looks like FORM'], 'Xfile.frm') call writefile(['looks like FORM'], 'Xfile.frm', 'D')
split Xfile.frm split Xfile.frm
call assert_equal('form', &filetype) call assert_equal('form', &filetype)
bwipe! bwipe!
@@ -1146,14 +1131,13 @@ func Test_frm_file()
call assert_equal('vb', &filetype) call assert_equal('vb', &filetype)
bwipe! bwipe!
call delete('Xfile.frm')
filetype off filetype off
endfunc endfunc
func Test_fs_file() func Test_fs_file()
filetype on filetype on
call writefile(['looks like F#'], 'Xfile.fs') call writefile(['looks like F#'], 'Xfile.fs', 'D')
split Xfile.fs split Xfile.fs
call assert_equal('fsharp', &filetype) call assert_equal('fsharp', &filetype)
bwipe! bwipe!
@@ -1199,14 +1183,13 @@ func Test_fs_file()
call assert_equal('forth', &filetype) call assert_equal('forth', &filetype)
bwipe! bwipe!
call delete('Xfile.fs')
filetype off filetype off
endfunc endfunc
func Test_git_file() func Test_git_file()
filetype on filetype on
call assert_true(mkdir('Xrepo.git', 'p')) call assert_true(mkdir('Xrepo.git', 'pR'))
call writefile([], 'Xrepo.git/HEAD') call writefile([], 'Xrepo.git/HEAD')
split Xrepo.git/HEAD split Xrepo.git/HEAD
@@ -1228,14 +1211,13 @@ func Test_git_file()
call assert_equal('git', &filetype) call assert_equal('git', &filetype)
bwipe! bwipe!
call delete('Xrepo.git', 'rf')
filetype off filetype off
endfunc endfunc
func Test_hook_file() func Test_hook_file()
filetype on filetype on
call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook') call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook', 'D')
split Xfile.hook split Xfile.hook
call assert_equal('conf', &filetype) call assert_equal('conf', &filetype)
bwipe! bwipe!
@@ -1245,7 +1227,6 @@ func Test_hook_file()
call assert_notequal('conf', &filetype) call assert_notequal('conf', &filetype)
bwipe! bwipe!
call delete('Xfile.hook')
filetype off filetype off
endfunc endfunc
@@ -1345,7 +1326,6 @@ func Test_m_file()
call assert_equal('murphi', &filetype) call assert_equal('murphi', &filetype)
bwipe! bwipe!
call delete('Xfile.m')
filetype off filetype off
endfunc endfunc
@@ -1427,7 +1407,7 @@ endfunc
func Test_patch_file() func Test_patch_file()
filetype on filetype on
call writefile([], 'Xfile.patch') call writefile([], 'Xfile.patch', 'D')
split Xfile.patch split Xfile.patch
call assert_equal('diff', &filetype) call assert_equal('diff', &filetype)
bwipe! bwipe!
@@ -1442,7 +1422,6 @@ func Test_patch_file()
call assert_equal('gitsendemail', &filetype) call assert_equal('gitsendemail', &filetype)
bwipe! bwipe!
call delete('Xfile.patch')
filetype off filetype off
endfunc endfunc
@@ -1454,19 +1433,18 @@ func Test_perl_file()
use a use a
END END
call writefile(lines, "Xfile.t") call writefile(lines, "Xfile.t", 'D')
split Xfile.t split Xfile.t
call assert_equal('perl', &filetype) call assert_equal('perl', &filetype)
bwipe bwipe
call delete('Xfile.t')
filetype off filetype off
endfunc endfunc
func Test_pp_file() func Test_pp_file()
filetype on filetype on
call writefile(['looks like puppet'], 'Xfile.pp') call writefile(['looks like puppet'], 'Xfile.pp', 'D')
split Xfile.pp split Xfile.pp
call assert_equal('puppet', &filetype) call assert_equal('puppet', &filetype)
bwipe! bwipe!
@@ -1488,7 +1466,6 @@ func Test_pp_file()
call assert_equal('pascal', &filetype) call assert_equal('pascal', &filetype)
bwipe! bwipe!
call delete('Xfile.pp')
filetype off filetype off
endfunc endfunc
@@ -1575,12 +1552,11 @@ endfunc
func Test_scd_file() func Test_scd_file()
filetype on filetype on
call writefile(['ijq(1)'], 'srcfile.scd') call writefile(['ijq(1)'], 'srcfile.scd', 'D')
split srcfile.scd split srcfile.scd
call assert_equal('scdoc', &filetype) call assert_equal('scdoc', &filetype)
bwipe!
call delete('srcfile.scd')
bwipe!
filetype off filetype off
endfunc endfunc
@@ -1684,7 +1660,7 @@ endfunc
func Test_tf_file() func Test_tf_file()
filetype on filetype on
call writefile([';;; TF MUD client is super duper cool'], 'Xfile.tf') call writefile([';;; TF MUD client is super duper cool'], 'Xfile.tf', 'D')
split Xfile.tf split Xfile.tf
call assert_equal('tf', &filetype) call assert_equal('tf', &filetype)
bwipe! bwipe!
@@ -1694,14 +1670,13 @@ func Test_tf_file()
call assert_equal('terraform', &filetype) call assert_equal('terraform', &filetype)
bwipe! bwipe!
call delete('Xfile.tf')
filetype off filetype off
endfunc endfunc
func Test_ts_file() func Test_ts_file()
filetype on filetype on
call writefile(['<?xml version="1.0" encoding="utf-8"?>'], 'Xfile.ts') call writefile(['<?xml version="1.0" encoding="utf-8"?>'], 'Xfile.ts', 'D')
split Xfile.ts split Xfile.ts
call assert_equal('xml', &filetype) call assert_equal('xml', &filetype)
bwipe! bwipe!
@@ -1711,14 +1686,13 @@ func Test_ts_file()
call assert_equal('typescript', &filetype) call assert_equal('typescript', &filetype)
bwipe! bwipe!
call delete('Xfile.ts')
filetype off filetype off
endfunc endfunc
func Test_ttl_file() func Test_ttl_file()
filetype on filetype on
call writefile(['@base <http://example.org/> .'], 'Xfile.ttl') call writefile(['@base <http://example.org/> .'], 'Xfile.ttl', 'D')
split Xfile.ttl split Xfile.ttl
call assert_equal('turtle', &filetype) call assert_equal('turtle', &filetype)
bwipe! bwipe!
@@ -1728,26 +1702,24 @@ func Test_ttl_file()
call assert_equal('teraterm', &filetype) call assert_equal('teraterm', &filetype)
bwipe! bwipe!
call delete('Xfile.ttl')
filetype off filetype off
endfunc endfunc
func Test_xpm_file() func Test_xpm_file()
filetype on filetype on
call writefile(['this is XPM2'], 'file.xpm') call writefile(['this is XPM2'], 'file.xpm', 'D')
split file.xpm split file.xpm
call assert_equal('xpm2', &filetype) call assert_equal('xpm2', &filetype)
bwipe! bwipe!
call delete('file.xpm')
filetype off filetype off
endfunc endfunc
func Test_cls_file() func Test_cls_file()
filetype on filetype on
call writefile(['looks like Smalltalk'], 'Xfile.cls') call writefile(['looks like Smalltalk'], 'Xfile.cls', 'D')
split Xfile.cls split Xfile.cls
call assert_equal('st', &filetype) call assert_equal('st', &filetype)
bwipe! bwipe!
@@ -1781,14 +1753,13 @@ func Test_cls_file()
call assert_equal('vb', &filetype) call assert_equal('vb', &filetype)
bwipe! bwipe!
call delete('Xfile.cls')
filetype off filetype off
endfunc endfunc
func Test_sig_file() func Test_sig_file()
filetype on filetype on
call writefile(['this is neither Lambda Prolog nor SML'], 'Xfile.sig') call writefile(['this is neither Lambda Prolog nor SML'], 'Xfile.sig', 'D')
split Xfile.sig split Xfile.sig
call assert_equal('', &filetype) call assert_equal('', &filetype)
bwipe! bwipe!
@@ -1835,7 +1806,6 @@ func Test_sig_file()
call assert_equal('sml', &filetype) call assert_equal('sml', &filetype)
bwipe! bwipe!
call delete('Xfile.sig')
filetype off filetype off
endfunc endfunc
@@ -1855,7 +1825,7 @@ func Test_sil_file()
let protoErasedPathA = let protoErasedPathA =
\ABCProtocol.a \ABCProtocol.a
END END
call writefile(lines, 'Xfile.sil') call writefile(lines, 'Xfile.sil', 'D')
split Xfile.sil split Xfile.sil
call assert_equal('sil', &filetype) call assert_equal('sil', &filetype)
@@ -1873,14 +1843,13 @@ func Test_sil_file()
call assert_equal('sile', &filetype) call assert_equal('sile', &filetype)
bwipe! bwipe!
call delete('Xfile.sil')
filetype off filetype off
endfunc endfunc
func Test_inc_file() func Test_inc_file()
filetype on filetype on
call writefile(['this is the fallback'], 'Xfile.inc') call writefile(['this is the fallback'], 'Xfile.inc', 'D')
split Xfile.inc split Xfile.inc
call assert_equal('pov', &filetype) call assert_equal('pov', &filetype)
bwipe! bwipe!
@@ -1952,7 +1921,6 @@ func Test_inc_file()
call assert_equal('foo', &filetype) call assert_equal('foo', &filetype)
bwipe! bwipe!
call delete('Xfile.inc')
filetype off filetype off
endfunc endfunc

View File

@@ -10,7 +10,7 @@ func Test_find_complete()
call delete("Xfind", "rf") call delete("Xfind", "rf")
let cwd = getcwd() let cwd = getcwd()
let test_out = cwd . '/test.out' let test_out = cwd . '/test.out'
call mkdir('Xfind') call mkdir('Xfind', 'R')
cd Xfind cd Xfind
new new
@@ -158,7 +158,6 @@ func Test_find_complete()
enew | only enew | only
call chdir(cwd) call chdir(cwd)
call delete('Xfind', 'rf')
set path& set path&
endfunc endfunc

View File

@@ -232,7 +232,7 @@ func Test_find_non_existing_path()
new new
let save_path = &path let save_path = &path
let save_dir = getcwd() let save_dir = getcwd()
call mkdir('dir1/dir2', 'p') call mkdir('dir1/dir2', 'pR')
call writefile([], 'dir1/file.txt') call writefile([], 'dir1/file.txt')
call writefile([], 'dir1/dir2/base.txt') call writefile([], 'dir1/dir2/base.txt')
call chdir('dir1/dir2') call chdir('dir1/dir2')
@@ -243,10 +243,6 @@ func Test_find_non_existing_path()
call chdir(save_dir) call chdir(save_dir)
bw! bw!
call delete('dir1/dir2/base.txt', 'rf')
call delete('dir1/dir2', 'rf')
call delete('dir1/file.txt', 'rf')
call delete('dir1', 'rf')
let &path = save_path let &path = save_path
endfunc endfunc

View File

@@ -137,7 +137,7 @@ func Test_indent_fold_with_read()
call assert_equal(1, foldlevel(n)) call assert_equal(1, foldlevel(n))
endfor endfor
call writefile(["a", "", "\<Tab>a"], 'Xinfofile') call writefile(["a", "", "\<Tab>a"], 'Xinfofile', 'D')
foldopen foldopen
2read Xinfofile 2read Xinfofile
%foldclose %foldclose
@@ -150,7 +150,6 @@ func Test_indent_fold_with_read()
bwipe! bwipe!
set foldmethod& set foldmethod&
call delete('Xinfofile')
endfunc endfunc
func Test_combining_folds_indent() func Test_combining_folds_indent()
@@ -216,7 +215,7 @@ func Test_update_folds_expr_read()
set foldexpr=s:TestFoldExpr(v:lnum) set foldexpr=s:TestFoldExpr(v:lnum)
2 2
foldopen foldopen
call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xupfofile') call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xupfofile', 'D')
read Xupfofile read Xupfofile
%foldclose %foldclose
call assert_equal(2, foldclosedend(1)) call assert_equal(2, foldclosedend(1))
@@ -226,7 +225,6 @@ func Test_update_folds_expr_read()
call assert_equal(10, foldclosedend(7)) call assert_equal(10, foldclosedend(7))
call assert_equal(14, foldclosedend(11)) call assert_equal(14, foldclosedend(11))
call delete('Xupfofile')
bwipe! bwipe!
set foldmethod& foldexpr& set foldmethod& foldexpr&
endfunc endfunc
@@ -808,7 +806,7 @@ func Test_folds_with_rnu()
call writefile([ call writefile([
\ 'set fdm=marker rnu foldcolumn=2', \ 'set fdm=marker rnu foldcolumn=2',
\ 'call setline(1, ["{{{1", "nline 1", "{{{1", "line 2"])', \ 'call setline(1, ["{{{1", "nline 1", "{{{1", "line 2"])',
\ ], 'Xtest_folds_with_rnu') \ ], 'Xtest_folds_with_rnu', 'D')
let buf = RunVimInTerminal('-S Xtest_folds_with_rnu', {}) let buf = RunVimInTerminal('-S Xtest_folds_with_rnu', {})
call VerifyScreenDump(buf, 'Test_folds_with_rnu_01', {}) call VerifyScreenDump(buf, 'Test_folds_with_rnu_01', {})
@@ -817,7 +815,6 @@ func Test_folds_with_rnu()
" clean up " clean up
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtest_folds_with_rnu')
endfunc endfunc
func Test_folds_marker_in_comment2() func Test_folds_marker_in_comment2()
@@ -1263,7 +1260,7 @@ func Test_foldclose_opt()
\ foldclosed(4)])], 'Xoutput', 'a') \ foldclosed(4)])], 'Xoutput', 'a')
endfunc endfunc
END END
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
let rows = 10 let rows = 10
let buf = RunVimInTerminal('-S Xscript', {'rows': rows}) let buf = RunVimInTerminal('-S Xscript', {'rows': rows})
call term_wait(buf) call term_wait(buf)
@@ -1292,7 +1289,6 @@ func Test_foldclose_opt()
call assert_equal(['[-1,2,2,-1]', '[-1,-1,-1,-1]', '[-1,2,2,-1]', call assert_equal(['[-1,2,2,-1]', '[-1,-1,-1,-1]', '[-1,2,2,-1]',
\ '[-1,-1,-1,-1]', '[-1,2,2,-1]'], readfile('Xoutput')) \ '[-1,-1,-1,-1]', '[-1,2,2,-1]'], readfile('Xoutput'))
call delete('Xscript')
call delete('Xoutput') call delete('Xoutput')
endfunc endfunc

View File

@@ -10,13 +10,11 @@
func Test_function_lists() func Test_function_lists()
" Delete any files left over from an earlier run of this test. " Delete any files left over from an earlier run of this test.
call delete("Xglobal_functions.diff") call delete("Xglobal_functions.diff")
call delete("Xfunctions.diff") call delete("Xfunctions.diff")
call delete("Xfunction-list.diff") call delete("Xfunction-list.diff")
" Create a file of the functions in evalfunc.c:global_functions[]. " Create a file of the functions in evalfunc.c:global_functions[].
enew! enew!
read ../evalfunc.c read ../evalfunc.c
1,/^static funcentry_T global_functions\[\] =$/d 1,/^static funcentry_T global_functions\[\] =$/d
@@ -28,7 +26,6 @@ func Test_function_lists()
w! Xglobal_functions w! Xglobal_functions
" Verify that those functions are in ASCII order. " Verify that those functions are in ASCII order.
sort u sort u
w! Xsorted_global_functions w! Xsorted_global_functions
let l:unequal = assert_equalfile("Xsorted_global_functions", "Xglobal_functions", let l:unequal = assert_equalfile("Xsorted_global_functions", "Xglobal_functions",
@@ -39,7 +36,6 @@ func Test_function_lists()
" Create a file of the functions in evalfunc.c:global_functions[] that are " Create a file of the functions in evalfunc.c:global_functions[] that are
" not obsolete, sorted in ASCII order. " not obsolete, sorted in ASCII order.
enew! enew!
read ../evalfunc.c read ../evalfunc.c
1,/^static funcentry_T global_functions\[\] =$/d 1,/^static funcentry_T global_functions\[\] =$/d
@@ -53,7 +49,6 @@ func Test_function_lists()
w! ++ff=unix Xsorted_current_global_functions w! ++ff=unix Xsorted_current_global_functions
" Verify that the ":help functions" list is complete and in ASCII order. " Verify that the ":help functions" list is complete and in ASCII order.
enew! enew!
if filereadable('../../doc/builtin.txt') if filereadable('../../doc/builtin.txt')
" unpacked MS-Windows zip archive " unpacked MS-Windows zip archive
@@ -77,7 +72,6 @@ func Test_function_lists()
endif endif
" Verify that the ":help function-list" list is complete. " Verify that the ":help function-list" list is complete.
enew! enew!
if filereadable('../../doc/usr_41.txt') if filereadable('../../doc/usr_41.txt')
" unpacked MS-Windows zip archive " unpacked MS-Windows zip archive

View File

@@ -1326,9 +1326,8 @@ func Test_filewritable()
call assert_equal(0, filewritable('doesnotexist')) call assert_equal(0, filewritable('doesnotexist'))
call mkdir('Xwritedir') call mkdir('Xwritedir', 'D')
call assert_equal(2, filewritable('Xwritedir')) call assert_equal(2, filewritable('Xwritedir'))
call delete('Xwritedir', 'd')
call delete('Xfilewritable') call delete('Xfilewritable')
bw! bw!
@@ -1661,7 +1660,7 @@ func Test_setbufvar_keep_window_title()
let g:buf = bufadd('Xb.txt') let g:buf = bufadd('Xb.txt')
inoremap <F2> <C-R>=setbufvar(g:buf, '&autoindent', 1) ?? ''<CR> inoremap <F2> <C-R>=setbufvar(g:buf, '&autoindent', 1) ?? ''<CR>
END END
call writefile(lines, 'Xsetbufvar') call writefile(lines, 'Xsetbufvar', 'D')
let buf = RunVimInTerminal('-S Xsetbufvar', {}) let buf = RunVimInTerminal('-S Xsetbufvar', {})
call WaitForAssert({-> assert_match('Xa.txt', term_gettitle(buf))}, 1000) call WaitForAssert({-> assert_match('Xa.txt', term_gettitle(buf))}, 1000)
@@ -1672,7 +1671,6 @@ func Test_setbufvar_keep_window_title()
call assert_match('Xa.txt', term_gettitle(buf)) call assert_match('Xa.txt', term_gettitle(buf))
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xsetbufvar')
endfunc endfunc
func Test_redo_in_nested_functions() func Test_redo_in_nested_functions()
@@ -1938,19 +1936,18 @@ endfunc
func Test_func_range_with_edit() func Test_func_range_with_edit()
" Define a function that edits another buffer, then call it with a range that " Define a function that edits another buffer, then call it with a range that
" is invalid in that buffer. " is invalid in that buffer.
call writefile(['just one line'], 'Xfuncrange2') call writefile(['just one line'], 'Xfuncrange2', 'D')
new new
eval 10->range()->setline(1) eval 10->range()->setline(1)
write Xfuncrange1 write Xfuncrange1
call assert_fails('5,8call EditAnotherFile()', 'E16:') call assert_fails('5,8call EditAnotherFile()', 'E16:')
call delete('Xfuncrange1') call delete('Xfuncrange1')
call delete('Xfuncrange2')
bwipe! bwipe!
endfunc endfunc
func Test_func_exists_on_reload() func Test_func_exists_on_reload()
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists') call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists', 'D')
call assert_equal(0, exists('*ExistingFunction')) call assert_equal(0, exists('*ExistingFunction'))
source Xfuncexists source Xfuncexists
call assert_equal(1, '*ExistingFunction'->exists()) call assert_equal(1, '*ExistingFunction'->exists())
@@ -1959,7 +1956,7 @@ func Test_func_exists_on_reload()
call assert_equal(1, exists('*ExistingFunction')) call assert_equal(1, exists('*ExistingFunction'))
" But redefining in another script is not OK. " But redefining in another script is not OK.
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2') call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2', 'D')
call assert_fails('source Xfuncexists2', 'E122:') call assert_fails('source Xfuncexists2', 'E122:')
" Defining a new function from the cmdline should fail if the function is " Defining a new function from the cmdline should fail if the function is
@@ -1975,8 +1972,6 @@ func Test_func_exists_on_reload()
call assert_fails('source Xfuncexists', 'E122:') call assert_fails('source Xfuncexists', 'E122:')
call assert_equal(1, exists('*ExistingFunction')) call assert_equal(1, exists('*ExistingFunction'))
call delete('Xfuncexists2')
call delete('Xfuncexists')
delfunc ExistingFunction delfunc ExistingFunction
endfunc endfunc
@@ -2063,7 +2058,7 @@ func Test_platform_name()
endfunc endfunc
func Test_readdir() func Test_readdir()
call mkdir('Xreaddir') call mkdir('Xreaddir', 'R')
call writefile([], 'Xreaddir/foo.txt') call writefile([], 'Xreaddir/foo.txt')
call writefile([], 'Xreaddir/bar.txt') call writefile([], 'Xreaddir/bar.txt')
call mkdir('Xreaddir/dir') call mkdir('Xreaddir/dir')
@@ -2092,12 +2087,10 @@ func Test_readdir()
" Nested readdir() must not crash " Nested readdir() must not crash
let files = readdir('Xreaddir', 'readdir("Xreaddir", "1") != []') let files = readdir('Xreaddir', 'readdir("Xreaddir", "1") != []')
call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt']) call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
eval 'Xreaddir'->delete('rf')
endfunc endfunc
func Test_readdirex() func Test_readdirex()
call mkdir('Xexdir') call mkdir('Xexdir', 'R')
call writefile(['foo'], 'Xexdir/foo.txt') call writefile(['foo'], 'Xexdir/foo.txt')
call writefile(['barbar'], 'Xexdir/bar.txt') call writefile(['barbar'], 'Xexdir/bar.txt')
call mkdir('Xexdir/dir') call mkdir('Xexdir/dir')
@@ -2144,7 +2137,6 @@ func Test_readdirex()
call sort(files)->assert_equal( call sort(files)->assert_equal(
\ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link']) \ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link'])
endif endif
eval 'Xexdir'->delete('rf')
call assert_fails('call readdirex("doesnotexist")', 'E484:') call assert_fails('call readdirex("doesnotexist")', 'E484:')
endfunc endfunc
@@ -2156,7 +2148,7 @@ func Test_readdirex_sort()
throw 'Skipped: Test_readdirex_sort on systems that do not allow this using the default filesystem' throw 'Skipped: Test_readdirex_sort on systems that do not allow this using the default filesystem'
endif endif
let _collate = v:collate let _collate = v:collate
call mkdir('Xsortdir2') call mkdir('Xsortdir2', 'R')
call writefile(['1'], 'Xsortdir2/README.txt') call writefile(['1'], 'Xsortdir2/README.txt')
call writefile(['2'], 'Xsortdir2/Readme.txt') call writefile(['2'], 'Xsortdir2/Readme.txt')
call writefile(['3'], 'Xsortdir2/readme.txt') call writefile(['3'], 'Xsortdir2/readme.txt')
@@ -2198,14 +2190,13 @@ func Test_readdirex_sort()
finally finally
exe 'lang collate' collate exe 'lang collate' collate
eval 'Xsortdir2'->delete('rf')
endtry endtry
endfunc endfunc
func Test_readdir_sort() func Test_readdir_sort()
" some more cases for testing sorting for readdirex " some more cases for testing sorting for readdirex
let dir = 'Xsortdir3' let dir = 'Xsortdir3'
call mkdir(dir) call mkdir(dir, 'R')
call writefile(['1'], dir .. '/README.txt') call writefile(['1'], dir .. '/README.txt')
call writefile(['2'], dir .. '/Readm.txt') call writefile(['2'], dir .. '/Readm.txt')
call writefile(['3'], dir .. '/read.txt') call writefile(['3'], dir .. '/read.txt')
@@ -2247,8 +2238,6 @@ func Test_readdir_sort()
" Cleanup " Cleanup
exe "lang collate" collate exe "lang collate" collate
eval dir->delete('rf')
endfunc endfunc
func Test_delete_rf() func Test_delete_rf()

View File

@@ -699,6 +699,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
611,
/**/ /**/
610, 610,
/**/ /**/