diff src/testdir/test_vim9_script.vim @ 24146:03fc95628eb0 v8.2.2614

patch 8.2.2614: Vim9: function is deleted while executing Commit: https://github.com/vim/vim/commit/c970e4225b68ff8650ff23df09e04246c147fca3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 17 15:03:04 2021 +0100 patch 8.2.2614: Vim9: function is deleted while executing Problem: Vim9: function is deleted while executing. Solution: increment the call count, when more than zero do not delete the function but mark it as dead. (closes #7977)
author Bram Moolenaar <Bram@vim.org>
date Wed, 17 Mar 2021 15:15:03 +0100
parents e8b21a3bb0d5
children 0edc315f2d0c
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1561,6 +1561,35 @@ def Test_script_reload_change_type()
   delete('Xreload.vim')
 enddef
 
+" Define CallFunc so that the test can be compiled
+command CallFunc echo 'nop'
+
+def Test_script_reload_from_function()
+  var lines =<< trim END
+      vim9script
+
+      if exists('g:loaded')
+        finish
+      endif
+      g:loaded = 1
+      delcommand CallFunc
+      command CallFunc Func()
+      def Func()
+        so /tmp/test.vim
+        g:didTheFunc = 1
+      enddef
+  END
+  writefile(lines, 'XreloadFunc.vim')
+  source XreloadFunc.vim
+  CallFunc
+  assert_equal(1, g:didTheFunc)
+
+  delete('XreloadFunc.vim')
+  delcommand CallFunc
+  unlet g:loaded
+  unlet g:didTheFunc
+enddef
+
 def Test_script_var_shadows_function()
   var lines =<< trim END
       vim9script