Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
call setline(1, ['{{{', 'abc', '}}}'])
%foldclose
END
- call writefile(lines, 'Xscript')
+ call writefile(lines, 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', {})
call assert_notequal('abc', term_getline(buf, 2))
call term_sendkeys(buf, "/abc\n")
" clean up
call StopVimInTerminal(buf)
- call delete('Xscript')
endfunc
" Test for using an lmap in insert mode
func GetIndent()
return line('.') * 2
endfunc
- call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt')
+ call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt', 'D')
set modelineexpr
new Xmlfile.txt
call assert_equal('GetIndent()', &indentexpr)
delfunc GetIndent
let &modeline = modeline
close!
- call delete('Xmlfile.txt')
endfunc
func Test_indent_func_with_gq()
set ff=unix
call writefile(["test11\t36Gepeto\t/Tag/",
\ "asd\ttest11file\t36G",
- \ "Makefile\tto\trun"], 'Xtestfile')
+ \ "Makefile\tto\trun"], 'Xtestfile', 'D')
call writefile(['', 'start of testfile',
\ 'ru',
\ 'run1',
\ 'run2',
\ 'STARTTEST',
\ 'ENDTEST',
- \ 'end of testfile'], 'Xtestdata')
+ \ 'end of testfile'], 'Xtestdata', 'D')
set ff&
enew!
call assert_equal('asd', getline('.'))
%bw!
- call delete('Xtestfile')
call delete('Xtest11.one')
call delete('Xtest11.two')
- call delete('Xtestdata')
set cpt& cot& def& tags& tagbsearch& hidden&
cd ..
call delete('Xcpldir', 'rf')
func Test_ins_complete_invalid_byte()
if has('unix') && executable('base64')
" this weird command was causing an illegal memory access
- call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64')
+ call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64', 'D')
call system('base64 -d Xinvalid64 > Xinvalid')
- call writefile(['qa!'], 'Xexit')
+ call writefile(['qa!'], 'Xexit', 'D')
call RunVim([], [], " -i NONE -n -X -Z -e -m -s -S Xinvalid -S Xexit")
- call delete('Xinvalid64')
call delete('Xinvalid')
- call delete('Xexit')
endif
endfunc
let save_rtp = &rtp
set rtp=Xruntime/some
let dir = 'Xruntime/some/autoload'
- call mkdir(dir, 'p')
+ call mkdir(dir, 'pR')
let lines =<< trim END
vim9script
call feedkeys("i\<C-X>\<C-O>\<Esc>", 'xt')
bwipe!
- call delete('Xruntime', 'rf')
set omnifunc=
let &rtp = save_rtp
endfunc
func Test_ins_completeslash()
CheckMSWindows
- call mkdir('Xcpldir')
+ call mkdir('Xcpldir', 'R')
let orig_shellslash = &shellslash
set cpt&
new
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir/', getline('.'))
%bw!
- call delete('Xcpldir', 'rf')
set noshellslash
set completeslash=slash
endfunc
END
- call writefile(lines, 'Xpumscript')
+ call writefile(lines, 'Xpumscript', 'D')
let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12})
call term_sendkeys(buf, ":call StartCompl()\<CR>")
call TermWait(buf, 200)
call VerifyScreenDump(buf, 'Test_pum_stopped_by_timer', {})
call StopVimInTerminal(buf)
- call delete('Xpumscript')
endfunc
func Test_complete_stopinsert_startinsert()
call feedkeys("0fa", 'xt')
END
- call writefile(lines, 'Xpumscript')
+ call writefile(lines, 'Xpumscript', 'D')
let buf = RunVimInTerminal('-S Xpumscript', #{rows: 10})
call TermWait(buf, 50)
call term_sendkeys(buf, "a\<C-N>")
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
- call delete('Xpumscript')
endfunc
func Test_pum_with_preview_win()
set completeopt+=longest
END
- call writefile(lines, 'Xpreviewscript')
+ call writefile(lines, 'Xpreviewscript', 'D')
let buf = RunVimInTerminal('-S Xpreviewscript', #{rows: 12})
call term_sendkeys(buf, "Gi\<C-X>\<C-O>")
call TermWait(buf, 200)
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
- call delete('Xpreviewscript')
endfunc
func Test_scrollbar_on_wide_char()
\ ' 呃呃呃'])
call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'}))
END
- call writefile(lines, 'Xwidescript')
+ call writefile(lines, 'Xwidescript', 'D')
let buf = RunVimInTerminal('-S Xwidescript', #{rows: 10})
call term_sendkeys(buf, "A\<C-N>")
call VerifyScreenDump(buf, 'Test_scrollbar_on_wide_char', {})
call StopVimInTerminal(buf)
- call delete('Xwidescript')
endfunc
" Test for inserting the tag search pattern in insert mode
\ "first\tXfoo\t/^int first() {}$/",
\ "second\tXfoo\t/^int second() {}$/",
\ "third\tXfoo\t/^int third() {}$/"],
- \ 'Xtags')
+ \ 'Xtags', 'D')
set tags=Xtags
let code =<< trim [CODE]
int first() {}
int second() {}
int third() {}
[CODE]
- call writefile(code, 'Xfoo')
+ call writefile(code, 'Xfoo', 'D')
enew
set showfulltag
call assert_equal('int second() {}', getline(1))
set noshowfulltag
- call delete('Xtags')
- call delete('Xfoo')
set tags&
%bwipe!
endfunc
" Test for completing words from unloaded buffers
func Test_complete_from_unloadedbuf()
- call writefile(['abc'], "Xfile1")
- call writefile(['def'], "Xfile2")
+ call writefile(['abc'], "Xfile1", 'D')
+ call writefile(['def'], "Xfile2", 'D')
edit Xfile1
edit Xfile2
new | close
call assert_equal('abc', getline(1))
exe "normal! od\<C-P>"
call assert_equal('def', getline(2))
+
set complete&
%bw!
- call delete("Xfile1")
- call delete("Xfile2")
endfunc
" Test for completing whole lines from unloaded buffers
func Test_complete_wholeline_unloadedbuf()
- call writefile(['a line1', 'a line2', 'a line3'], "Xfile1")
+ call writefile(['a line1', 'a line2', 'a line3'], "Xfile1", 'D')
edit Xfile1
enew
set complete=u
bdel Xfile1
exe "normal! ia\<C-X>\<C-L>\<C-P>"
call assert_equal('a', getline(1))
+
set complete&
%bw!
- call delete("Xfile1")
endfunc
" Test for completing words from unlisted buffers
func Test_complete_from_unlistedbuf()
- call writefile(['abc'], "Xfile1")
- call writefile(['def'], "Xfile2")
+ call writefile(['abc'], "Xfile1", 'D')
+ call writefile(['def'], "Xfile2", 'D')
edit Xfile1
edit Xfile2
new | close
call assert_equal('abc', getline(1))
exe "normal! od\<C-P>"
call assert_equal('def', getline(2))
+
set complete&
%bw!
- call delete("Xfile1")
- call delete("Xfile2")
endfunc
" Test for completing whole lines from unlisted buffers
func Test_complete_wholeline_unlistedbuf()
- call writefile(['a line1', 'a line2', 'a line3'], "Xfile1")
+ call writefile(['a line1', 'a line2', 'a line3'], "Xfile1", 'D')
edit Xfile1
enew
set complete=U
bdel Xfile1
exe "normal! ia\<C-X>\<C-L>\<C-P>"
call assert_equal('a line2', getline(1))
+
set complete&
%bw!
- call delete("Xfile1")
endfunc
" Test for adding a multibyte character using CTRL-L in completion mode
CheckUnix
CheckNotRoot
- call writefile(['about', 'above'], 'Xunrfile')
+ call writefile(['about', 'above'], 'Xunrfile', 'D')
call setfperm('Xunrfile', '---r--r--')
new
set complete=sXfile
exe "normal! ia\<C-P>"
call assert_equal('a', getline(1))
+
bw!
- call delete('Xunrfile')
set complete&
endfunc
for i in range(1, 100)
call add(lines, "Line " . i)
endfor
- call writefile(lines, "Xtest")
+ call writefile(lines, "Xtest", 'D')
" Jump around and create a jump list
edit Xtest
clearjumps
call test_garbagecollect_now()
call assert_equal(4, l[1])
-
- call delete("Xtest")
endfunc
func Test_jumplist_invalid()
return 1
endfunc
END
- call writefile(l, 'Xscript')
+ call writefile(l, 'Xscript', 'D')
let caught_932 = 0
try
source Xscript
let caught_932 = 1
endtry
call assert_equal(1, caught_932)
- call delete('Xscript')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
let v =<< that there
endfunc
END
- call writefile(text, 'XheredocFail')
+ call writefile(text, 'XheredocFail', 'D')
call assert_fails('source XheredocFail', 'E1145:')
- call delete('XheredocFail')
let text =<< trim CodeEnd
func MissingEnd()
let v =<< END
endfunc
CodeEnd
- call writefile(text, 'XheredocWrong')
+ call writefile(text, 'XheredocWrong', 'D')
call assert_fails('source XheredocWrong', 'E1145:')
- call delete('XheredocWrong')
let text =<< trim TEXTend
let v =<< " comment
TEXTend
- call writefile(text, 'XheredocNoMarker')
+ call writefile(text, 'XheredocNoMarker', 'D')
call assert_fails('source XheredocNoMarker', 'E172:')
- call delete('XheredocNoMarker')
let text =<< trim TEXTend
let v =<< text
TEXTend
- call writefile(text, 'XheredocBadMarker')
+ call writefile(text, 'XheredocBadMarker', 'D')
call assert_fails('source XheredocBadMarker', 'E221:')
- call delete('XheredocBadMarker')
- call writefile(['let v =<< TEXT', 'abc'], 'XheredocMissingMarker')
+ call writefile(['let v =<< TEXT', 'abc'], 'XheredocMissingMarker', 'D')
call assert_fails('source XheredocMissingMarker', 'E990:')
- call delete('XheredocMissingMarker')
endfunc
func Test_let_heredoc_trim_no_indent_marker()
vsplit
windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:<
END
- call writefile(lines, 'XTest_listchars')
+ call writefile(lines, 'XTest_listchars', 'D')
let buf = RunVimInTerminal('-S XTest_listchars', {'rows': 10, 'cols': 60})
" clean up
call StopVimInTerminal(buf)
- call delete('XTest_listchars')
endfunc
" Test :luafile foo.lua
func Test_luafile()
- call delete('Xlua_file')
- call writefile(["str = 'hello'", "num = 123" ], 'Xlua_file')
+ call writefile(["str = 'hello'", "num = 123" ], 'Xlua_file', 'D')
call setfperm('Xlua_file', 'r-xr-xr-x')
luafile Xlua_file
call assert_equal(123, luaeval('num'))
lua str, num = nil
- call delete('Xlua_file')
endfunc
" Test :luafile %
" Test :luafile with syntax error
func Test_luafile_error()
new Xlua_file
- call writefile(['nil = 0' ], 'Xlua_file')
+ call writefile(['nil = 0' ], 'Xlua_file', 'D')
call setfperm('Xlua_file', 'r-xr-xr-x')
call assert_fails('luafile Xlua_file', "Xlua_file:1: unexpected symbol near 'nil'")
- call delete('Xlua_file')
bwipe!
endfunc
call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
exec "norm! G\<C-E>\<C-E>"
END
- call writefile(lines, 'Xscript')
+ call writefile(lines, 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', {})
" wait for the script to finish
call term_sendkeys(buf, "\<Esc>u")
call StopVimInTerminal(buf)
- call delete('Xscript')
endfunc
func Test_balloon_split()
123456789_123456789_123456789_b
123
END
- call writefile(lines, 'Xtest')
+ call writefile(lines, 'Xtest', 'D')
let buf = RunVimInTerminal('Xtest', {})
call term_sendkeys(buf, ":vsplit\<CR>")
call term_sendkeys(buf, "\<Esc>u")
call StopVimInTerminal(buf)
- call delete('Xtest')
endfunc
func Test_popup_command()
echomsg 'changed'
endfunc
END
- call writefile(script, 'XtimerScript')
+ call writefile(script, 'XtimerScript', 'D')
let lines =<< trim END
one two three four five
and one two Xthree four five
one more two three four five
END
- call writefile(lines, 'Xtest')
+ call writefile(lines, 'Xtest', 'D')
let buf = RunVimInTerminal('-S XtimerScript Xtest', {})
call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\<CR>")
call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
call VerifyScreenDump(buf, 'Test_popup_command_05', {})
call StopVimInTerminal(buf)
- call delete('Xtest')
- call delete('XtimerScript')
endfunc
func Test_popup_complete_backwards()
inoremap <buffer><F6> <C-R>=s:complTestEval()<CR>
call writefile([
\ 'dummy dummy.txt 1',
- \], 'Xdummy.txt')
+ \], 'Xdummy.txt', 'D')
setlocal tags=Xdummy.txt
setlocal dictionary=Xdummy.txt
setlocal thesaurus=Xdummy.txt
call assert_equal(mode_name, getline('.'))
%d
endfor
- call delete('Xdummy.txt')
+
bwipe!
endfunc
vim
victory
END
- call writefile(lines, 'Xtest1')
+ call writefile(lines, 'Xtest1', 'D')
let buf = RunVimInTerminal('--cmd "set rightleft" Xtest1', {})
call term_sendkeys(buf, "Go\<C-P>")
call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8})
one three
four
END
- call writefile(lines, 'Xtest2')
+ call writefile(lines, 'Xtest2', 'D')
call term_sendkeys(buf, "\<Esc>:e! Xtest2\<CR>")
call TermWait(buf, 30)
call term_sendkeys(buf, "Goone\<C-X>\<C-L>")
call WaitForAssert({-> assert_match('\s*eerht eno', Screenline(4))})
call StopVimInTerminal(buf)
- call delete('Xtest1')
- call delete('Xtest2')
endfunc
" Test for a popup menu with a scrollbar
two
three
END
- call writefile(lines, 'Xtest1')
+ call writefile(lines, 'Xtest1', 'D')
let buf = RunVimInTerminal('--cmd "set pumheight=2" Xtest1', {})
call TermWait(buf)
call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>")
endif
call StopVimInTerminal(buf)
- call delete('Xtest1')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 625,
/**/
624,
/**/