summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-25 15:41:11 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-25 15:41:11 +0200
commit925e9fd6339981c1015410e1b6a6dd19e34f36cc (patch)
tree8dde93c048e748625c3014eeeab243b7af3804cf /src/testdir
parentc841afff6a89592f23710c6da5b0fea89b240937 (diff)
patch 8.2.1290: Vim9: cannot replace a global functionv8.2.1290
Problem: Vim9: cannot replace a global function. Solution: Allow for "!" on a global function. (closes #6524) Also fix that :delfunc on a :def function only made it empty.
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_vim9_script.vim48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 3e2ced0a93..f7d195ea83 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -468,6 +468,54 @@ def Test_delfunction()
'enddef',
'DoThat()',
], 'E1084:')
+
+ # Check that global :def function can be replaced and deleted
+ let lines =<< trim END
+ vim9script
+ def g:Global(): string
+ return "yes"
+ enddef
+ assert_equal("yes", g:Global())
+ def! g:Global(): string
+ return "no"
+ enddef
+ assert_equal("no", g:Global())
+ delfunc g:Global
+ assert_false(exists('*g:Global'))
+ END
+ CheckScriptSuccess(lines)
+
+ # Check that global function can be replaced by a :def function and deleted
+ lines =<< trim END
+ vim9script
+ func g:Global()
+ return "yes"
+ endfunc
+ assert_equal("yes", g:Global())
+ def! g:Global(): string
+ return "no"
+ enddef
+ assert_equal("no", g:Global())
+ delfunc g:Global
+ assert_false(exists('*g:Global'))
+ END
+ CheckScriptSuccess(lines)
+
+ # Check that global :def function can be replaced by a function and deleted
+ lines =<< trim END
+ vim9script
+ def g:Global(): string
+ return "yes"
+ enddef
+ assert_equal("yes", g:Global())
+ func! g:Global()
+ return "no"
+ endfunc
+ assert_equal("no", g:Global())
+ delfunc g:Global
+ assert_false(exists('*g:Global'))
+ END
+ CheckScriptSuccess(lines)
enddef
func Test_wrong_type()