Mercurial > vim
comparison src/testdir/test_expand.vim @ 28403:2655935b5ccc v8.2.4726
patch 8.2.4726: cannot use expand() to get the script name
Commit: https://github.com/vim/vim/commit/6013d0045dec7ca7c0068fbe186c42d754a7368b
Author: LemonBoy <thatlemon@gmail.com>
Date: Sat Apr 9 21:42:10 2022 +0100
patch 8.2.4726: cannot use expand() to get the script name
Problem: Cannot use expand() to get the script name.
Solution: Support expand('<script>'). (closes https://github.com/vim/vim/issues/10121)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 09 Apr 2022 22:45:03 +0200 |
parents | 425700af491b |
children | 4fbdd4ce9edb |
comparison
equal
deleted
inserted
replaced
28402:401c4206d38c | 28403:2655935b5ccc |
---|---|
157 func Test_expandcmd_shell_nonomatch() | 157 func Test_expandcmd_shell_nonomatch() |
158 CheckNotMSWindows | 158 CheckNotMSWindows |
159 call assert_equal('$*', expandcmd('$*')) | 159 call assert_equal('$*', expandcmd('$*')) |
160 endfunc | 160 endfunc |
161 | 161 |
162 func Test_expand_script_source() | |
163 let lines0 =<< trim [SCRIPT] | |
164 let g:script_level[0] = expand('<script>:t') | |
165 so Xscript1 | |
166 func F0() | |
167 let g:func_level[0] = expand('<script>:t') | |
168 endfunc | |
169 [SCRIPT] | |
170 | |
171 let lines1 =<< trim [SCRIPT] | |
172 let g:script_level[1] = expand('<script>:t') | |
173 so Xscript2 | |
174 func F1() | |
175 let g:func_level[1] = expand('<script>:t') | |
176 endfunc | |
177 [SCRIPT] | |
178 | |
179 let lines2 =<< trim [SCRIPT] | |
180 let g:script_level[2] = expand('<script>:t') | |
181 func F2() | |
182 let g:func_level[2] = expand('<script>:t') | |
183 endfunc | |
184 [SCRIPT] | |
185 | |
186 call writefile(lines0, 'Xscript0') | |
187 call writefile(lines1, 'Xscript1') | |
188 call writefile(lines2, 'Xscript2') | |
189 | |
190 " Check the expansion of <script> at script and function level. | |
191 let g:script_level = ['', '', ''] | |
192 let g:func_level = ['', '', ''] | |
193 | |
194 so Xscript0 | |
195 call F0() | |
196 call F1() | |
197 call F2() | |
198 | |
199 call assert_equal(['Xscript0', 'Xscript1', 'Xscript2'], g:script_level) | |
200 call assert_equal(['Xscript0', 'Xscript1', 'Xscript2'], g:func_level) | |
201 | |
202 unlet g:script_level g:func_level | |
203 delfunc F0 | |
204 delfunc F1 | |
205 delfunc F2 | |
206 | |
207 call delete('Xscript0') | |
208 call delete('Xscript1') | |
209 call delete('Xscript2') | |
210 endfunc | |
211 | |
162 " vim: shiftwidth=2 sts=2 expandtab | 212 " vim: shiftwidth=2 sts=2 expandtab |