summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_expand.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_expand.vim')
-rw-r--r--src/testdir/test_expand.vim50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/testdir/test_expand.vim b/src/testdir/test_expand.vim
index 638f9c7c34..fee5f2fe86 100644
--- a/src/testdir/test_expand.vim
+++ b/src/testdir/test_expand.vim
@@ -159,4 +159,54 @@ func Test_expandcmd_shell_nonomatch()
call assert_equal('$*', expandcmd('$*'))
endfunc
+func Test_expand_script_source()
+ let lines0 =<< trim [SCRIPT]
+ let g:script_level[0] = expand('<script>:t')
+ so Xscript1
+ func F0()
+ let g:func_level[0] = expand('<script>:t')
+ endfunc
+ [SCRIPT]
+
+ let lines1 =<< trim [SCRIPT]
+ let g:script_level[1] = expand('<script>:t')
+ so Xscript2
+ func F1()
+ let g:func_level[1] = expand('<script>:t')
+ endfunc
+ [SCRIPT]
+
+ let lines2 =<< trim [SCRIPT]
+ let g:script_level[2] = expand('<script>:t')
+ func F2()
+ let g:func_level[2] = expand('<script>:t')
+ endfunc
+ [SCRIPT]
+
+ call writefile(lines0, 'Xscript0')
+ call writefile(lines1, 'Xscript1')
+ call writefile(lines2, 'Xscript2')
+
+ " Check the expansion of <script> at script and function level.
+ let g:script_level = ['', '', '']
+ let g:func_level = ['', '', '']
+
+ so Xscript0
+ call F0()
+ call F1()
+ call F2()
+
+ call assert_equal(['Xscript0', 'Xscript1', 'Xscript2'], g:script_level)
+ call assert_equal(['Xscript0', 'Xscript1', 'Xscript2'], g:func_level)
+
+ unlet g:script_level g:func_level
+ delfunc F0
+ delfunc F1
+ delfunc F2
+
+ call delete('Xscript0')
+ call delete('Xscript1')
+ call delete('Xscript2')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab