aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_functions.vim
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-05 14:10:32 -0700
committerJustin M. Keyes <justinkz@gmail.com>2019-09-05 14:10:32 -0700
commit8b06231612cd608b2dce5e0a09bf40192a4803cb (patch)
tree04fbfef7b326574e296b2fe1a772829ac0af8be4 /src/nvim/testdir/test_functions.vim
parent096212d52c6375c19c046d86a7178bae91e287fc (diff)
parentd3f1eb3024fa297c970a79dd24ef818e4aeb8525 (diff)
downloadrneovim-8b06231612cd608b2dce5e0a09bf40192a4803cb.tar.gz
rneovim-8b06231612cd608b2dce5e0a09bf40192a4803cb.tar.bz2
rneovim-8b06231612cd608b2dce5e0a09bf40192a4803cb.zip
Merge #10869 'vim-patch:8.1.{0309,0362,0365,0515,1946}'
Diffstat (limited to 'src/nvim/testdir/test_functions.vim')
-rw-r--r--src/nvim/testdir/test_functions.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 6c3d944ad5..a36c51f56f 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -1067,6 +1067,33 @@ func Test_func_range_with_edit()
bwipe!
endfunc
+func Test_func_exists_on_reload()
+ call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
+ call assert_equal(0, exists('*ExistingFunction'))
+ source Xfuncexists
+ call assert_equal(1, exists('*ExistingFunction'))
+ " Redefining a function when reloading a script is OK.
+ source Xfuncexists
+ call assert_equal(1, exists('*ExistingFunction'))
+
+ " But redefining in another script is not OK.
+ call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
+ call assert_fails('source Xfuncexists2', 'E122:')
+
+ delfunc ExistingFunction
+ call assert_equal(0, exists('*ExistingFunction'))
+ call writefile([
+ \ 'func ExistingFunction()', 'echo "yes"', 'endfunc',
+ \ 'func ExistingFunction()', 'echo "no"', 'endfunc',
+ \ ], 'Xfuncexists')
+ call assert_fails('source Xfuncexists', 'E122:')
+ call assert_equal(1, exists('*ExistingFunction'))
+
+ call delete('Xfuncexists2')
+ call delete('Xfuncexists')
+ delfunc ExistingFunction
+endfunc
+
sandbox function Fsandbox()
normal ix
endfunc