comparison src/testdir/test_usercommands.vim @ 15125:b101b193d5ff v8.1.0573

patch 8.1.0573: cannot redefine user command without ! in same script commit https://github.com/vim/vim/commit/55d46913084745a48749d7ac4f48930852e1d87e Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 8 16:03:28 2018 +0100 patch 8.1.0573: cannot redefine user command without ! in same script Problem: Cannot redefine user command without ! in same script Solution: Allow redefining user command without ! in same script, like with functions.
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Dec 2018 16:15:05 +0100
parents 39728d503e47
children 250420b35b10
comparison
equal deleted inserted replaced
15124:27c801cca007 15125:b101b193d5ff
88 Do 88 Do
89 call assert_equal('also', g:didthat) 89 call assert_equal('also', g:didthat)
90 delcommand Dothat 90 delcommand Dothat
91 endfunc 91 endfunc
92 92
93 func Test_redefine_on_reload()
94 call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists')
95 call assert_equal(0, exists(':ExistingCommand'))
96 source Xcommandexists
97 call assert_equal(2, exists(':ExistingCommand'))
98 " Redefining a command when reloading a script is OK.
99 source Xcommandexists
100 call assert_equal(2, exists(':ExistingCommand'))
101
102 " But redefining in another script is not OK.
103 call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists2')
104 call assert_fails('source Xcommandexists2', 'E174:')
105 call delete('Xcommandexists2')
106
107 " And defining twice in one script is not OK.
108 delcommand ExistingCommand
109 call assert_equal(0, exists(':ExistingCommand'))
110 call writefile([
111 \ 'command ExistingCommand echo "yes"',
112 \ 'command ExistingCommand echo "no"',
113 \ ], 'Xcommandexists')
114 call assert_fails('source Xcommandexists', 'E174:')
115 call assert_equal(2, exists(':ExistingCommand'))
116
117 call delete('Xcommandexists')
118 delcommand ExistingCommand
119 endfunc
120
93 func Test_CmdUndefined() 121 func Test_CmdUndefined()
94 call assert_fails('Doit', 'E492:') 122 call assert_fails('Doit', 'E492:')
95 au CmdUndefined Doit :command Doit let g:didit = 'yes' 123 au CmdUndefined Doit :command Doit let g:didit = 'yes'
96 Doit 124 Doit
97 call assert_equal('yes', g:didit) 125 call assert_equal('yes', g:didit)