diff src/testdir/test_usercommands.vim @ 30867:0913cd44fdfa v9.0.0768

patch 9.0.0768: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/5b148ef2628251b2d79f78c65a614f8aca404329 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 15 21:35:56 2022 +0100 patch 9.0.0768: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Oct 2022 22:45:02 +0200
parents a3016780f346
children 8c7495056f35
line wrap: on
line diff
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -239,7 +239,7 @@ func Test_Ambiguous()
 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 @@ func Test_redefine_on_reload()
   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 @@ func Test_redefine_on_reload()
   call assert_fails('source Xcommandexists', 'E174:')
   call assert_equal(2, exists(':ExistingCommand'))
 
-  call delete('Xcommandexists')
   delcommand ExistingCommand
 endfunc
 
@@ -849,7 +847,7 @@ func Test_block_declaration_legacy_scrip
                      @a = save
                 }
   END
-  call writefile(lines, 'Xlegacy')
+  call writefile(lines, 'Xlegacy', 'D')
   source Xlegacy
 
   let lines =<< trim END
@@ -864,12 +862,10 @@ func Test_block_declaration_legacy_scrip
       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