0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -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

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