aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-14 06:32:00 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-15 10:14:52 +0800
commit98ab0bb5f7d2138be0b6019769e237e42aafad1a (patch)
tree6899f42d0caeed8cd23a386669b3adf40d987989 /src/nvim/testdir
parent1c164689a4ef243be2a0e1b4332c9b6c56b5b031 (diff)
downloadrneovim-98ab0bb5f7d2138be0b6019769e237e42aafad1a.tar.gz
rneovim-98ab0bb5f7d2138be0b6019769e237e42aafad1a.tar.bz2
rneovim-98ab0bb5f7d2138be0b6019769e237e42aafad1a.zip
vim-patch:8.2.1297: when a test fails it's often not easy to see where
Problem: When a test fails it's often not easy to see what the call stack is. Solution: Add more entries from the call stack in the exception message. https://github.com/vim/vim/commit/a5d0423fa16f18b4576a2a07e50034e489587a7d Use docs from latest Vim.
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_expand_func.vim19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim
index b48c2e8a19..388620f87e 100644
--- a/src/nvim/testdir/test_expand_func.vim
+++ b/src/nvim/testdir/test_expand_func.vim
@@ -37,17 +37,28 @@ func Test_expand_sflnum()
delcommand Flnum
endfunc
-func Test_expand_sfile()
+func Test_expand_sfile_and_stack()
call assert_match('test_expand_func\.vim$', s:sfile)
- call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>'))
+ let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$'
+ call assert_match(expected , expand('<sfile>'))
+ call assert_match(expected , expand('<stack>'))
" Call in script-local function
- call assert_match('^function .*\.\.Test_expand_sfile\[5\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile())
+ call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile())
" Call in command
command Sfile echo expand('<sfile>')
- call assert_match('^function .*\.\.Test_expand_sfile$', trim(execute('Sfile')))
+ call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$', trim(execute('Sfile')))
delcommand Sfile
+
+ " Use <stack> from sourced script.
+ let lines =<< trim END
+ let g:stack_value = expand('<stack>')
+ END
+ call writefile(lines, 'Xstack')
+ source Xstack
+ call assert_match('\<Xstack$', g:stack_value)
+ call delete('Xstack')
endfunc
func Test_expand_slnum()