diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-15 20:06:33 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-15 20:06:33 +0100 |
commit | 0e9bdad545e8e75b23c40e44cc6ec51330f5b465 (patch) | |
tree | 97d4e5cf151ada69600c5ad10cc85cbdbca6a129 /src | |
parent | 36343ae0fb7247e060abfd35fb8e4337b33abb4b (diff) |
patch 9.0.0766: too many delete() calls in testsv9.0.0766
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 13 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 21 | ||||
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 9 | ||||
-rw-r--r-- | src/testdir/test_vim9_disassemble.vim | 95 | ||||
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 10 | ||||
-rw-r--r-- | src/testdir/test_vim9_import.vim | 297 | ||||
-rw-r--r-- | src/version.c | 2 |
7 files changed, 158 insertions, 289 deletions
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index c552461aad..610a36ce4c 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -921,9 +921,8 @@ def Test_vim9_single_char_vars() assert_equal(333, v) assert_equal(444, w) END - writefile(lines, 'Xsinglechar') + writefile(lines, 'Xsinglechar', 'D') source Xsinglechar - delete('Xsinglechar') enddef def Test_assignment_list() @@ -1940,13 +1939,12 @@ def Test_var_func_call() # env var is always a string var env = $TERM END - writefile(lines, 'Xfinished') + writefile(lines, 'Xfinished', 'D') source Xfinished # GetValue() is not called during discovery phase assert_equal(1, g:count) unlet g:count - delete('Xfinished') enddef def Test_var_missing_type() @@ -2532,7 +2530,7 @@ def Test_unlet() 'DelChangedtick(b:)', ], 'E795:') - writefile(['vim9script', 'export var svar = 1234'], 'XunletExport.vim') + writefile(['vim9script', 'export var svar = 1234'], 'XunletExport.vim', 'D') var lines =<< trim END vim9script import './XunletExport.vim' as exp @@ -2542,7 +2540,6 @@ def Test_unlet() defcompile END v9.CheckScriptFailure(lines, 'E1260:', 1) - delete('XunletExport.vim') $ENVVAR = 'foobar' assert_equal('foobar', $ENVVAR) @@ -2701,11 +2698,9 @@ def Test_abort_after_error() var x: string x = strpart(1, 2) END - writefile(lines, 'Xtestscript') + writefile(lines, 'Xtestscript', 'D') var expected = 'E1174: String required for argument 1' assert_fails('so Xtestscript', [expected, expected], 3) - - delete('Xtestscript') enddef def Test_using_s_var_in_function() diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 13c61bcf8c..e9ec43930e 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -12,7 +12,7 @@ func Test_internalfunc_arg_error() enddef defcompile END - call writefile(l, 'Xinvalidarg') + call writefile(l, 'Xinvalidarg', 'D') call assert_fails('so Xinvalidarg', 'E118:', '', 1, 'FArgErr') let l =<< trim END def! FArgErr(): float @@ -22,7 +22,6 @@ func Test_internalfunc_arg_error() END call writefile(l, 'Xinvalidarg') call assert_fails('so Xinvalidarg', 'E119:', '', 1, 'FArgErr') - call delete('Xinvalidarg') endfunc " Test for builtin functions returning different types @@ -52,7 +51,7 @@ func Test_InternalFuncRetType() return environ() enddef END - call writefile(lines, 'Xscript') + call writefile(lines, 'Xscript', 'D') source Xscript call RetFloat()->assert_equal(2.0) @@ -61,7 +60,6 @@ func Test_InternalFuncRetType() call RetListDictAny()->assert_notequal([]) call RetDictNumber()->assert_notequal({}) call RetDictString()->assert_notequal({}) - call delete('Xscript') endfunc def Test_abs() @@ -1984,7 +1982,7 @@ def Test_getscriptinfo() def g:Xscript_def_func2() enddef END - writefile(lines1, 'X22script92') + writefile(lines1, 'X22script92', 'D') var lines2 =<< trim END source X22script92 @@ -2006,7 +2004,6 @@ def Test_getscriptinfo() endfor END v9.CheckDefAndScriptSuccess(lines2) - delete('X22script92') enddef def Test_gettabinfo() @@ -3238,7 +3235,7 @@ enddef def Test_readblob() var blob = 0z12341234 - writefile(blob, 'Xreadblob') + writefile(blob, 'Xreadblob', 'D') var read: blob = readblob('Xreadblob') assert_equal(blob, read) @@ -3247,12 +3244,11 @@ def Test_readblob() END v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<string> but got blob', 1) v9.CheckDefExecAndScriptFailure(['readblob("")'], 'E484: Can''t open file <empty>') - delete('Xreadblob') enddef def Test_readfile() var text = ['aaa', 'bbb', 'ccc'] - writefile(text, 'Xreadfile') + writefile(text, 'Xreadfile', 'D') var read: list<string> = readfile('Xreadfile') assert_equal(text, read) assert_equal([7, 7, 7], readfile('Xreadfile')->map((_, _) => 7)) @@ -3261,7 +3257,6 @@ def Test_readfile() var read: dict<string> = readfile('Xreadfile') END v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got list<string>', 1) - delete('Xreadfile') v9.CheckDefAndScriptFailure(['readfile("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2']) v9.CheckDefAndScriptFailure(['readfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3']) @@ -4131,9 +4126,8 @@ def Test_sort_compare_func_fails() vim9script echo ['a', 'b', 'c']->sort((a: number, b: number) => 0) END - writefile(lines, 'Xbadsort') + writefile(lines, 'Xbadsort', 'D') assert_fails('source Xbadsort', ['E1013:', 'E702:']) - delete('Xbadsort') lines =<< trim END var l = [1, 2, 3] @@ -4822,7 +4816,7 @@ func Test_win_gotoid_in_mapping() call feedkeys("\<F3>\<LeftMouse>\<LeftRelease>", "xt") endfunc END - call writefile(lines, 'Xgotoscript') + call writefile(lines, 'Xgotoscript', 'D') let buf = RunVimInTerminal('-S Xgotoscript', #{rows: 15, wait_for_ruler: 0}) " wait longer here, since we didn't wait for the ruler call VerifyScreenDump(buf, 'Test_win_gotoid_1', #{wait: 3000}) @@ -4833,7 +4827,6 @@ func Test_win_gotoid_in_mapping() call VerifyScreenDump(buf, 'Test_win_gotoid_3', {}) call StopVimInTerminal(buf) - call delete('Xgotoscript') endif endfunc diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 1a3f5df82c..4e89c7ffca 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -120,12 +120,11 @@ def Test_cmdmod_execute() vim9script export var exported = 'x' END - writefile(lines, 'Xvim9import.vim') + writefile(lines, 'Xvim9import.vim', 'D') lines =<< trim END legacy exe "import './Xvim9import.vim'" END v9.CheckScriptSuccess(lines) - delete('Xvim9import.vim') # "legacy" does not aply to a called function lines =<< trim END @@ -331,7 +330,7 @@ def Test_hardcopy_wildcards() enddef def Test_syn_include_wildcards() - writefile(['syn keyword Found found'], 'Xthemine.vim') + writefile(['syn keyword Found found'], 'Xthemine.vim', 'D') var save_rtp = &rtp &rtp = '.' @@ -340,7 +339,6 @@ def Test_syn_include_wildcards() assert_match('Found.* contained found', execute('syn list Found')) &rtp = save_rtp - delete('Xthemine.vim') enddef def Test_echo_linebreak() @@ -932,7 +930,7 @@ func Test_command_modifier_confirm() confirm write Xcmodfile enddef END - call writefile(lines, 'Xconfirmscript') + call writefile(lines, 'Xconfirmscript', 'D') call writefile(['empty'], 'Xcmodfile') let buf = RunVimInTerminal('-S Xconfirmscript', {'rows': 8}) call term_sendkeys(buf, ":call Getout()\n") @@ -946,7 +944,6 @@ func Test_command_modifier_confirm() call assert_equal(['changed'], readfile('Xcmodfile')) call delete('Xcmodfile') call delete('.Xcmodfile.swp') " in case Vim was killed - call delete('Xconfirmscript') endfunc def Test_command_modifiers_keep() diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index 56d7f0c66f..e47e013764 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -313,7 +313,7 @@ def s:ScriptFuncPush() enddef def Test_disassemble_push() - mkdir('Xdisdir/autoload', 'p') + mkdir('Xdisdir/autoload', 'pR') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Xdisdir' @@ -340,12 +340,11 @@ def Test_disassemble_push() END v9.CheckScriptSuccess(lines) - delete('Xdisdir', 'rf') &rtp = save_rtp enddef def Test_disassemble_import_autoload() - writefile(['vim9script'], 'XimportAL.vim') + writefile(['vim9script'], 'XimportAL.vim', 'D') var lines =<< trim END vim9script @@ -380,8 +379,6 @@ def Test_disassemble_import_autoload() res) END v9.CheckScriptSuccess(lines) - - delete('XimportAL.vim') enddef def s:ScriptFuncStore() @@ -2440,7 +2437,7 @@ def Test_vim9script_forward_func() enddef g:res_FuncOne = execute('disass FuncOne') END - writefile(lines, 'Xdisassemble') + writefile(lines, 'Xdisassemble', 'D') source Xdisassemble # check that the first function calls the second with DCALL @@ -2450,7 +2447,6 @@ def Test_vim9script_forward_func() '\d RETURN', g:res_FuncOne) - delete('Xdisassemble') unlet g:res_FuncOne enddef @@ -2901,51 +2897,50 @@ def Test_disassemble_nextcmd() enddef def Test_disassemble_after_reload() - var lines =<< trim END - vim9script - if exists('g:ThisFunc') - finish - endif - var name: any - def g:ThisFunc(): number - g:name = name - return 0 - enddef - def g:ThatFunc(): number - name = g:name - return 0 - enddef - END - lines->writefile('Xreload.vim') - - source Xreload.vim - g:ThisFunc() - g:ThatFunc() - - source Xreload.vim - var res = execute('disass g:ThisFunc') - assert_match('ThisFunc\_s*' .. - 'g:name = name\_s*' .. - '\d LOADSCRIPT \[deleted\] from .*/Xreload.vim\_s*' .. - '\d STOREG g:name\_s*' .. - 'return 0\_s*' .. - '\d PUSHNR 0\_s*' .. - '\d RETURN\_s*', - res) + var lines =<< trim END + vim9script + if exists('g:ThisFunc') + finish + endif + var name: any + def g:ThisFunc(): number + g:name = name + return 0 + enddef + def g:ThatFunc(): number + name = g:name + return 0 + enddef + END + lines->writefile('Xreload.vim', 'D') + + source Xreload.vim + g:ThisFunc() + g:ThatFunc() + + source Xreload.vim + var res = execute('disass g:ThisFunc') + assert_match('ThisFunc\_s*' .. + 'g:name = name\_s*' .. + '\d LOADSCRIPT \[deleted\] from .*/Xreload.vim\_s*' .. + '\d STOREG g:name\_s*' .. + 'return 0\_s*' .. + '\d PUSHNR 0\_s*' .. + '\d RETURN\_s*', + res) - res = execute('disass g:ThatFunc') - assert_match('ThatFunc\_s*' .. - 'name = g:name\_s*' .. - '\d LOADG g:name\_s*' .. - '\d STORESCRIPT \[deleted\] in .*/Xreload.vim\_s*' .. - 'return 0\_s*' .. - '\d PUSHNR 0\_s*' .. - '\d RETURN\_s*', - res) + res = execute('disass g:ThatFunc') + assert_match('ThatFunc\_s*' .. + 'name = g:name\_s*' .. + '\d LOADG g:name\_s*' .. + '\d STORESCRIPT \[deleted\] in .*/Xreload.vim\_s*' .. + 'return 0\_s*' .. + '\d PUSHNR 0\_s*' .. + '\d RETURN\_s*', + res) - delete('Xreload.vim') - delfunc g:ThisFunc - delfunc g:ThatFunc + delfunc g:ThisFunc + delfunc g:ThatFunc enddef def s:MakeString(x: number): string diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 44e221a90f..b764e929cf 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -3490,7 +3490,7 @@ def Test_expr9_autoload_var() var auto_lines =<< trim END let autofile#var = 'found' END - mkdir('Xruntime/autoload', 'p') + mkdir('Xruntime/autoload', 'pR') writefile(auto_lines, 'Xruntime/autoload/autofile.vim') var save_rtp = &rtp &rtp = getcwd() .. '/Xruntime,' .. &rtp @@ -3506,7 +3506,6 @@ def Test_expr9_autoload_var() v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: autofile#other') &rtp = save_rtp - delete('Xruntime', 'rf') enddef def Test_expr9_call_autoload() @@ -3515,7 +3514,7 @@ def Test_expr9_call_autoload() return 'found' enddef END - mkdir('Xruntime/autoload', 'p') + mkdir('Xruntime/autoload', 'pR') writefile(auto_lines, 'Xruntime/autoload/some.vim') var save_rtp = &rtp &rtp = getcwd() .. '/Xruntime,' .. &rtp @@ -3523,7 +3522,6 @@ def Test_expr9_call_autoload() assert_equal('found', some#func()) &rtp = save_rtp - delete('Xruntime', 'rf') enddef def Test_expr9_method_call() @@ -3640,7 +3638,7 @@ def Test_expr9_method_call_import() return map(items, (_, i) => i * i) enddef END - call writefile(lines, 'Xsquare.vim') + call writefile(lines, 'Xsquare.vim', 'D') lines =<< trim END vim9script @@ -3663,8 +3661,6 @@ def Test_expr9_method_call_import() echo range(5)->Xsquare.NoSuchFunc() END v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NoSuchFunc') - - delete('Xsquare.vim') enddef diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 6fe40234e4..dba91c3a3f 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -39,7 +39,7 @@ def s:Undo_export_script_lines() enddef def Test_vim9_import_export() - writefile(s:export_script_lines, 'Xexport.vim') + writefile(s:export_script_lines, 'Xexport.vim', 'D') var import_script_lines =<< trim END vim9script var dir = './' @@ -84,7 +84,7 @@ def Test_vim9_import_export() assert_equal('andthensome', 'andthen'->expo.AddSome()) assert_equal('awesome', 'awe'->expo.AddRef()) END - writefile(import_script_lines, 'Ximport.vim') + writefile(import_script_lines, 'Ximport.vim', 'D') source Ximport.vim assert_equal('bobbie', g:result) @@ -380,9 +380,6 @@ def Test_vim9_import_export() writefile(import_assign_const_lines, 'Ximport.vim') assert_fails('source Ximport.vim', 'E46: Cannot change read-only variable "CONST"', '', 3) - delete('Ximport.vim') - delete('Xexport.vim') - # Check that in a Vim9 script 'cpo' is set to the Vim default. # Flags added or removed are also applied to the restored value. set cpo=abcd @@ -393,7 +390,7 @@ def Test_vim9_import_export() set cpo-=c g:cpo_after_vim9script = &cpo END - writefile(lines, 'Xvim9_script') + writefile(lines, 'Xvim9_script', 'D') source Xvim9_script assert_equal('fabd', &cpo) set cpo&vim @@ -410,7 +407,7 @@ def Test_import_very_long_name() export var verylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongnameverylongname = 'asdf' END - writefile(lines, 'Xverylong.vim') + writefile(lines, 'Xverylong.vim', 'D') lines =<< trim END vim9script @@ -421,7 +418,6 @@ def Test_import_very_long_name() v9.CheckScriptSuccess(lines) assert_equal('asdf', g:result) - delete('Xverylong.vim') unlet g:result enddef @@ -433,7 +429,7 @@ def Test_import_funcref() enddef export const G = F END - writefile(lines, 'Xlib.vim') + writefile(lines, 'Xlib.vim', 'D') lines =<< trim END vim9script @@ -448,8 +444,6 @@ def Test_import_funcref() DoTest() END v9.CheckScriptSuccess(lines) - - delete('Xlib.vim') enddef def Test_export_closure() @@ -485,7 +479,7 @@ def Test_import_duplicate_function() NewLspServer() END - writefile(lines, 'Xserver.vim') + writefile(lines, 'Xserver.vim', 'D') lines =<< trim END vim9script @@ -502,13 +496,11 @@ def Test_import_duplicate_function() AddServer() END v9.CheckScriptSuccess(lines) - - delete('Xserver.vim') enddef def Test_import_fails() - writefile([], 'Xfoo.vim') + writefile([], 'Xfoo.vim', 'D') var lines =<< trim END import './Xfoo.vim' as foo foo = 'bar' @@ -588,11 +580,10 @@ def Test_import_fails() export var item = 'hello' import './Xyourself.vim' END - writefile(lines, 'Xyourself.vim') + writefile(lines, 'Xyourself.vim', 'D') assert_fails('source Xyourself.vim', 'E1088:') - delete('Xyourself.vim') - mkdir('Ximport') + mkdir('Ximport', 'R') writefile(['vim9script'], 'Ximport/.vim') lines =<< trim END @@ -635,9 +626,6 @@ def Test_import_fails() call writefile(['vim9script', "import './Xfoo.vim' as abc | foobar"], 'Xbar.vim') assert_fails('source Xbar.vim', 'E492: Not an editor command: foobar') call delete('Xbar.vim') - - delete('Ximport', 'rf') - delete('Xfoo.vim') enddef func g:Trigger() @@ -653,26 +641,24 @@ def Test_import_export_expr_map() return 'yes' enddef END - writefile(export_lines, 'Xexport_that.vim') + writefile(export_lines, 'Xexport_that.vim', 'D') var import_lines =<< trim END vim9script import './Xexport_that.vim' as that assert_equal('yes', that.That()) END - writefile(import_lines, 'Ximport.vim') + writefile(import_lines, 'Ximport.vim', 'D') nnoremap <expr> trigger g:Trigger() feedkeys('trigger', "xt") - delete('Xexport_that.vim') - delete('Ximport.vim') nunmap trigger enddef def Test_import_in_filetype() # check that :import works when the buffer is locked - mkdir('ftplugin', 'p') + mkdir('ftplugin', 'pR') var export_lines =<< trim END vim9script export var That = 'yes' @@ -695,8 +681,6 @@ def Test_import_in_filetype() assert_equal(1, g:did_load_mytpe) quit! - delete('Xexport_ft.vim') - delete('ftplugin', 'rf') &rtp = save_rtp enddef @@ -707,7 +691,7 @@ def Test_use_import_in_mapping() g:result = nr enddef END - writefile(lines, 'XsomeExport.vim') + writefile(lines, 'XsomeExport.vim', 'D') lines =<< trim END vim9script import './XsomeExport.vim' as some @@ -715,7 +699,7 @@ def Test_use_import_in_mapping() nnoremap <F3> :call <sid>Funcy(42)<cr> nnoremap <F4> :call <sid>some.Funcx(44)<cr> END - writefile(lines, 'Xmapscript.vim') + writefile(lines, 'Xmapscript.vim', 'D') source Xmapscript.vim feedkeys("\<F3>", "xt") @@ -724,8 +708,6 @@ def Test_use_import_in_mapping() assert_equal(44, g:result) unlet g:result - delete('XsomeExport.vim') - delete('Xmapscript.vim') nunmap <F3> nunmap <F4> enddef @@ -737,13 +719,13 @@ def Test_use_relative_autoload_import_in_mapping() g:result = 42 enddef END - writefile(lines, 'XrelautoloadExport.vim') + writefile(lines, 'XrelautoloadExport.vim', 'D') lines =<< trim END vim9script import autoload './XrelautoloadExport.vim' as some nnoremap <F3> :call <SID>some.Func()<CR> END - writefile(lines, 'Xmapscript.vim') + writefile(lines, 'Xmapscript.vim', 'D') source Xmapscript.vim assert_match('\d\+ A: .*XrelautoloadExport.vim', execute('scriptnames')->split("\n")[-1]) @@ -759,8 +741,6 @@ def Test_use_relative_autoload_import_in_mapping() assert_equal(999999, l[0].version) unlet g:result - delete('XrelautoloadExport.vim') - delete('Xmapscript.vim') nunmap <F3> enddef @@ -781,7 +761,7 @@ def Test_use_autoload_import_in_mapping() g:result = 49 enddef END - mkdir('Ximpdir/autoload', 'p') + mkdir('Ximpdir/autoload', 'pR') writefile(lines, 'Ximpdir/autoload/XautoloadExport.vim') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Ximpdir' @@ -791,7 +771,7 @@ def Test_use_autoload_import_in_mapping() import autoload 'XautoloadExport.vim' as some nnoremap <F3> :call <SID>some.Func()<CR> END - writefile(lines, 'Xmapscript.vim') + writefile(lines, 'Xmapscript.vim', 'D') source Xmapscript.vim assert_match('\d\+ A: .*autoload/XautoloadExport.vim', execute('scriptnames')->split("\n")[-1]) @@ -799,9 +779,7 @@ def Test_use_autoload_import_in_mapping() assert_equal(49, g:result) unlet g:result - delete('Xmapscript.vim') nunmap <F3> - delete('Ximpdir', 'rf') &rtp = save_rtp enddef @@ -812,7 +790,7 @@ def Test_use_import_in_command_completion() return ['abcd'] enddef END - writefile(lines, 'Xscript.vim') + writefile(lines, 'Xscript.vim', 'D') lines =<< trim END vim9script @@ -825,7 +803,6 @@ def Test_use_import_in_command_completion() v9.CheckScriptSuccess(lines) delcommand Cmd - delete('Xscript.vim') enddef def Test_use_import_with_funcref_in_command_completion() @@ -835,7 +812,7 @@ def Test_use_import_with_funcref_in_command_completion() return ['abcd'] enddef END - writefile(lines, 'Xscript.vim') + writefile(lines, 'Xscript.vim', 'D') lines =<< trim END vim9script @@ -849,11 +826,10 @@ def Test_use_import_with_funcref_in_command_completion() v9.CheckScriptSuccess(lines) delcommand Cmd - delete('Xscript.vim') enddef def Test_use_autoload_import_in_insert_completion() - mkdir('Xinsdir/autoload', 'p') + mkdir('Xinsdir/autoload', 'pR') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Xinsdir' @@ -889,12 +865,11 @@ def Test_use_autoload_import_in_insert_completion() set thesaurusfunc= bwipe! - delete('Xinsdir', 'rf') &rtp = save_rtp enddef def Test_use_autoload_import_partial_in_opfunc() - mkdir('Xpartdir/autoload', 'p') + mkdir('Xpartdir/autoload', 'pR') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Xpartdir' @@ -922,13 +897,12 @@ def Test_use_autoload_import_partial_in_opfunc() set opfunc= bwipe! - delete('Xpartdir', 'rf') nunmap <F3> &rtp = save_rtp enddef def Test_set_opfunc_to_autoload_func_directly() - mkdir('Xdirdir/autoload', 'p') + mkdir('Xdirdir/autoload', 'pR') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Xdirdir' @@ -956,13 +930,12 @@ def Test_set_opfunc_to_autoload_func_directly() set opfunc= bwipe! - delete('Xdirdir', 'rf') nunmap <F3> &rtp = save_rtp enddef def Test_use_autoload_import_in_fold_expression() - mkdir('Xfolddir/autoload', 'p') + mkdir('Xfolddir/autoload', 'pR') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Xfolddir' @@ -1000,7 +973,6 @@ def Test_use_autoload_import_in_fold_expression() set foldexpr= foldtext& foldmethod& debug= bwipe! - delete('Xfolddir', 'rf') &rtp = save_rtp enddef @@ -1019,11 +991,11 @@ def Test_autoload_import_relative() export var someText = 'some text' var notexp = 'bad' END - writefile(lines, 'XimportRel.vim') - writefile(lines, 'XimportRel2.vim') - writefile(lines, 'XimportRel3.vim') - writefile(lines, 'XimportRel4.vim') - writefile(lines, 'XimportRel5.vim') + writefile(lines, 'XimportRel.vim', 'D') + writefile(lines, 'XimportRel2.vim', 'D') + writefile(lines, 'XimportRel3.vim', 'D') + writefile(lines, 'XimportRel4.vim', 'D') + writefile(lines, 'XimportRel5.vim', 'D') lines =<< trim END vim9script @@ -1166,16 +1138,10 @@ def Test_autoload_import_relative() DoIt() END v9.CheckScriptFailure(lines, 'E484:') - - delete('XimportRel.vim') - delete('XimportRel2.vim') - delete('XimportRel3.vim') - delete('XimportRel4.vim') - delete('XimportRel5.vim') enddef def Test_autoload_import_relative_autoload_dir() - mkdir('autoload', 'p') + mkdir('autoload', 'pR') var lines =<< trim END vim9script export def Bar() @@ -1196,7 +1162,6 @@ def Test_autoload_import_relative_autoload_dir() v9.CheckScriptSuccess(lines) unlet g:called_bar - delete('autoload', 'rf') enddef def Test_autoload_import_deleted() @@ -1204,7 +1169,7 @@ def Test_autoload_import_deleted() vim9script export const FOO = 1 END - writefile(lines, 'Xa.vim') + writefile(lines, 'Xa.vim', 'D') lines =<< trim END vim9script @@ -1214,8 +1179,6 @@ def Test_autoload_import_deleted() var x = Xa.FOO END v9.CheckScriptFailure(lines, 'E484:') - - delete('Xa.vim') enddef def Test_autoload_import_using_const() @@ -1255,7 +1218,7 @@ def Run_Test_import_in_diffexpr() .. v:fname_new .. '>>' .. v:fname_out enddef END - writefile(lines, 'Xdiffexpr') + writefile(lines, 'Xdiffexpr', 'D') lines =<< trim END vim9script @@ -1281,7 +1244,6 @@ def Run_Test_import_in_diffexpr() set diffopt& bwipe! bwipe! - delete('Xdiffexpr') enddef def Test_import_in_patchexpr() @@ -1291,7 +1253,7 @@ def Test_import_in_patchexpr() call writefile(['output file'], v:fname_out) enddef END - writefile(lines, 'Xpatchexpr') + writefile(lines, 'Xpatchexpr', 'D') lines =<< trim END vim9script @@ -1300,16 +1262,13 @@ def Test_import_in_patchexpr() END v9.CheckScriptSuccess(lines) - call writefile(['input file'], 'Xinput') - call writefile(['diff file'], 'Xdiff') + call writefile(['input file'], 'Xinput', 'D') + call writefile(['diff file'], 'Xdiff', 'D') :%bwipe! edit Xinput diffpatch Xdiff call assert_equal('output file', getline(1)) - call delete('Xinput') - call delete('Xdiff') - call delete('Xpatchexpr') set patchexpr& :%bwipe! enddef @@ -1322,7 +1281,7 @@ def Test_import_in_formatexpr() return 0 enddef END - writefile(lines, 'Xformatter') + writefile(lines, 'Xformatter', 'D') lines =<< trim END vim9script @@ -1337,13 +1296,12 @@ def Test_import_in_formatexpr() assert_equal('yes', g:did_format) bwipe! - delete('Xformatter') unlet g:did_format set formatexpr= enddef def Test_import_in_includeexpr() - writefile(['found it'], 'Xthisfile') + writefile(['found it'], 'Xthisfile', 'D') new var lines =<< trim END @@ -1352,7 +1310,7 @@ def Test_import_in_includeexpr() return substitute(v:fname, 'that', 'this', '') enddef END - writefile(lines, 'Xinclude.vim') + writefile(lines, 'Xinclude.vim', 'D') lines =<< trim END vim9script @@ -1368,8 +1326,6 @@ def Test_import_in_includeexpr() bwipe! bwipe! set includeexpr= - delete('Xinclude.vim') - delete('Xthisfile') enddef def Test_import_in_indentexpr() @@ -1379,7 +1335,7 @@ def Test_import_in_indentexpr() return 5 enddef END - writefile(lines, 'Xindenter') + writefile(lines, 'Xindenter', 'D') lines =<< trim END vim9script @@ -1396,7 +1352,6 @@ def Test_import_in_indentexpr() bwipe! set indentexpr= debug= - delete('Xindenter') enddef func Test_import_in_printexpr() @@ -1413,7 +1368,7 @@ def Run_Test_import_in_printexpr() return false enddef END - writefile(lines, 'Xprint.vim') + writefile(lines, 'Xprint.vim', 'D') lines =<< trim END vim9script @@ -1426,7 +1381,6 @@ def Run_Test_import_in_printexpr() hardcopy dummy args assert_equal('yes', g:printed) - delete('Xprint.vim') set printexpr= enddef @@ -1440,7 +1394,7 @@ def Test_import_in_charconvert() return false # success enddef END - writefile(lines, 'Xconvert.vim') + writefile(lines, 'Xconvert.vim', 'D') lines =<< trim END vim9script @@ -1449,14 +1403,12 @@ def Test_import_in_charconvert() END v9.CheckScriptSuccess(lines) - writefile(['one', 'two'], 'Xiicfile') + writefile(['one', 'two'], 'Xiicfile', 'D') new Xiicfile write ++enc=ucase Xiicfile1 assert_equal(['ONE', 'TWO'], readfile('Xiicfile1')) - delete('Xiicfile') delete('Xiicfile1') - delete('Xconvert.vim') bwipe! set charconvert& enddef @@ -1473,7 +1425,7 @@ def Run_Test_import_in_spellsuggest_expr() return [['Fox', 8], ['Fop', 9]] enddef END - writefile(lines, 'Xsuggest.vim') + writefile(lines, 'Xsuggest.vim', 'D') lines =<< trim END vim9script @@ -1485,7 +1437,6 @@ def Run_Test_import_in_spellsuggest_expr() set verbose=1 # report errors call assert_equal(['Fox', 'Fop'], spellsuggest('Fo', 2)) - delete('Xsuggest.vim') set nospell spellsuggest& verbose=0 enddef @@ -1496,7 +1447,7 @@ def Test_import_in_lambda_method() return e enddef END - writefile(lines, 'XexportRetarg.vim') + writefile(lines, 'XexportRetarg.vim', 'D') lines =<< trim END vim9script import './XexportRetarg.vim' @@ -1507,12 +1458,10 @@ def Test_import_in_lambda_method() assert_equal('arg', Lambda()) END v9.CheckScriptSuccess(lines) - - delete('XexportRetarg.vim') enddef def Test_export_shadows_global_function() - mkdir('Xglobdir/autoload', 'p') + mkdir('Xglobdir/autoload', 'pR') var save_rtp = &rtp exe 'set rtp^=' .. getcwd() .. '/Xglobdir' @@ -1538,7 +1487,6 @@ def Test_export_shadows_global_function() delfunc g:Shadow bwipe! - delete('Xglobdir', 'rf') &rtp = save_rtp enddef @@ -1565,13 +1513,12 @@ def Run_Test_import_fails_on_command_line() return 0 enddef END - writefile(export, 'XexportCmd.vim') + writefile(export, 'XexportCmd.vim', 'D') var buf = g:RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { rows: 6, wait_for_ruler: 0}) g:WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) - delete('XexportCmd.vim') g:StopVimInTerminal(buf) enddef @@ -1583,7 +1530,7 @@ def Test_vim9_reload_noclear() export def TheFunc(x = 0) enddef END - writefile(lines, 'XExportReload') + writefile(lines, 'XExportReload', 'D') lines =<< trim END vim9script noclear g:loadCount += 1 @@ -1609,7 +1556,7 @@ def Test_vim9_reload_noclear() return 'once' enddef END - writefile(lines, 'XReloaded') + writefile(lines, 'XReloaded', 'D') g:loadCount = 0 source XReloaded assert_equal(1, g:loadCount) @@ -1621,8 +1568,6 @@ def Test_vim9_reload_noclear() assert_equal(3, g:loadCount) assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) - delete('XReloaded') - delete('XExportReload') delfunc g:Values unlet g:loadCount @@ -1631,7 +1576,7 @@ def Test_vim9_reload_noclear() def Inner() enddef END - lines->writefile('XreloadScript.vim') + lines->writefile('XreloadScript.vim', 'D') source XreloadScript.vim lines =<< trim END @@ -1644,8 +1589,6 @@ def Test_vim9_reload_noclear() END lines->writefile('XreloadScript.vim') source XreloadScript.vim - - delete('XreloadScript.vim') enddef def Test_vim_reload_noclear_arg_count() @@ -1668,7 +1611,7 @@ def Test_vim_reload_noclear_arg_count() Call() g:didload = 1 END - lines->writefile('XreloadScript_1.vim') + lines->writefile('XreloadScript_1.vim', 'D') source XreloadScript_1.vim assert_fails('source XreloadScript_1.vim', 'E1106: One argument too many') unlet g:didload @@ -1692,7 +1635,7 @@ def Test_vim_reload_noclear_arg_count() Call() g:didload = 1 END - lines->writefile('XreloadScript_2.vim') + lines->writefile('XreloadScript_2.vim', 'D') source XreloadScript_2.vim assert_fails('source XreloadScript_2.vim', 'E1106: 2 arguments too many') unlet g:didload @@ -1716,7 +1659,7 @@ def Test_vim_reload_noclear_arg_count() Call() g:didload = 1 END - lines->writefile('XreloadScript_3.vim') + lines->writefile('XreloadScript_3.vim', 'D') source Xrelo |