Mercurial > vim
comparison src/testdir/test_expand_func.vim @ 29754:32f358d71ec2 v9.0.0217
patch 9.0.0217: 'shellslash' works differently when sourcing a script again
Commit: https://github.com/vim/vim/commit/5a4fff4d948cd12a5cf5f637ad2c561815a77d8e
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon Aug 15 17:53:55 2022 +0100
patch 9.0.0217: 'shellslash' works differently when sourcing a script again
Problem: 'shellslash' works differently when sourcing a script again.
Solution: Use the name from the script item. (closes https://github.com/vim/vim/issues/10920)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 15 Aug 2022 19:00:03 +0200 |
parents | 5cf6dee0f305 |
children | ea38db8639eb |
comparison
equal
deleted
inserted
replaced
29753:dc388902b2f7 | 29754:32f358d71ec2 |
---|---|
39 | 39 |
40 func Test_expand_sfile_and_stack() | 40 func Test_expand_sfile_and_stack() |
41 call assert_match('test_expand_func\.vim$', s:sfile) | 41 call assert_match('test_expand_func\.vim$', s:sfile) |
42 let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack' | 42 let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack' |
43 call assert_match(expected .. '$', expand('<sfile>')) | 43 call assert_match(expected .. '$', expand('<sfile>')) |
44 call assert_match(expected .. '\[4\]' , expand('<stack>')) | 44 call assert_match(expected .. '\[4\]$' , expand('<stack>')) |
45 | 45 |
46 " Call in script-local function | 46 " Call in script-local function |
47 call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile()) | 47 call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile()) |
48 | 48 |
49 " Call in command | 49 " Call in command |
57 let g:stack_value = expand('<stack>') | 57 let g:stack_value = expand('<stack>') |
58 END | 58 END |
59 call writefile(lines, 'Xstack') | 59 call writefile(lines, 'Xstack') |
60 source Xstack | 60 source Xstack |
61 call assert_match('\<Xstack\[2\]$', g:stack_value) | 61 call assert_match('\<Xstack\[2\]$', g:stack_value) |
62 unlet g:stack_value | |
62 call delete('Xstack') | 63 call delete('Xstack') |
64 | |
65 if exists('+shellslash') | |
66 call mkdir('Xshellslash') | |
67 let lines =<< trim END | |
68 let g:stack1 = expand('<stack>') | |
69 set noshellslash | |
70 let g:stack2 = expand('<stack>') | |
71 set shellslash | |
72 let g:stack3 = expand('<stack>') | |
73 END | |
74 call writefile(lines, 'Xshellslash/Xstack') | |
75 " Test that changing 'shellslash' always affects the result of expand() | |
76 " when sourcing a script multiple times. | |
77 for i in range(2) | |
78 source Xshellslash/Xstack | |
79 call assert_match('\<Xshellslash/Xstack\[1\]$', g:stack1) | |
80 call assert_match('\<Xshellslash\\Xstack\[3\]$', g:stack2) | |
81 call assert_match('\<Xshellslash/Xstack\[5\]$', g:stack3) | |
82 unlet g:stack1 | |
83 unlet g:stack2 | |
84 unlet g:stack3 | |
85 endfor | |
86 call delete('Xshellslash', 'rf') | |
87 endif | |
63 endfunc | 88 endfunc |
64 | 89 |
65 func Test_expand_slnum() | 90 func Test_expand_slnum() |
66 call assert_equal(6, s:slnum) | 91 call assert_equal(6, s:slnum) |
67 call assert_equal(2, str2nr(expand('<slnum>'))) | 92 call assert_equal(2, str2nr(expand('<slnum>'))) |