patch 9.0.0768: too many delete() calls in tests
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim
index 8a41004..961aeb2 100644
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -239,7 +239,7 @@
endfunc
func Test_redefine_on_reload()
- call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists')
+ call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists', 'D')
call assert_equal(0, exists(':ExistingCommand'))
source Xcommandexists
call assert_equal(2, exists(':ExistingCommand'))
@@ -248,9 +248,8 @@
call assert_equal(2, exists(':ExistingCommand'))
" But redefining in another script is not OK.
- call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists2')
+ call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists2', 'D')
call assert_fails('source Xcommandexists2', 'E174:')
- call delete('Xcommandexists2')
" And defining twice in one script is not OK.
delcommand ExistingCommand
@@ -262,7 +261,6 @@
call assert_fails('source Xcommandexists', 'E174:')
call assert_equal(2, exists(':ExistingCommand'))
- call delete('Xcommandexists')
delcommand ExistingCommand
endfunc
@@ -849,7 +847,7 @@
@a = save
}
END
- call writefile(lines, 'Xlegacy')
+ call writefile(lines, 'Xlegacy', 'D')
source Xlegacy
let lines =<< trim END
@@ -864,12 +862,10 @@
call assert_equal('something', g:someExpr)
call assert_equal('also', @a)
END
- call writefile(lines, 'Xother')
+ call writefile(lines, 'Xother', 'D')
source Xother
unlet g:someExpr
- call delete('Xlegacy')
- call delete('Xother')
delcommand Rename
endfunc