aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2019-08-29 13:07:03 +0900
committererw7 <erw7.github@gmail.com>2019-09-04 13:40:05 +0900
commit9db60b06a1d9b50b3ba6beb858eb0fd2c58571c4 (patch)
treebd7d55a5af91afae726345b7fc40324625241879 /src/nvim/testdir
parente4a47862415ee6e0c4904f9c5cc8c3453be6bf17 (diff)
downloadrneovim-9db60b06a1d9b50b3ba6beb858eb0fd2c58571c4.tar.gz
rneovim-9db60b06a1d9b50b3ba6beb858eb0fd2c58571c4.tar.bz2
rneovim-9db60b06a1d9b50b3ba6beb858eb0fd2c58571c4.zip
vim-patch:8.1.0515: reloading a script gives errors for existing functions
Problem: Reloading a script gives errors for existing functions. Solution: Allow redefining a function once when reloading a script. https://github.com/vim/vim/commit/ded5f1bed7ff2d138b3ee0f9610d17290b62692d
Diffstat (limited to 'src/nvim/testdir')
-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