Mercurial > vim
comparison src/testdir/test_expand_func.vim @ 21493:7449921216bc v8.2.1297
patch 8.2.1297: when a test fails it's often not easy to see where
Commit: https://github.com/vim/vim/commit/a5d0423fa16f18b4576a2a07e50034e489587a7d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 26 15:37:02 2020 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Jul 2020 15:45:04 +0200 |
parents | 546bdeef35f1 |
children | 5daca8504c63 |
comparison
equal
deleted
inserted
replaced
21492:fb81749507a4 | 21493:7449921216bc |
---|---|
14 | 14 |
15 func s:expand_sflnum() | 15 func s:expand_sflnum() |
16 return str2nr(expand('<sflnum>')) | 16 return str2nr(expand('<sflnum>')) |
17 endfunc | 17 endfunc |
18 | 18 |
19 func Test_expand_sfile() | 19 " This test depends on the location in the test file, put it first. |
20 call assert_match('test_expand_func\.vim$', s:sfile) | 20 func Test_expand_sflnum() |
21 call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>')) | 21 call assert_equal(5, s:sflnum) |
22 call assert_equal(22, str2nr(expand('<sflnum>'))) | |
23 | |
24 " Line-continuation | |
25 call assert_equal( | |
26 \ 25, | |
27 \ str2nr(expand('<sflnum>'))) | |
22 | 28 |
23 " Call in script-local function | 29 " Call in script-local function |
24 call assert_match('^function .*\.\.Test_expand_sfile\[5\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile()) | 30 call assert_equal(16, s:expand_sflnum()) |
31 | |
32 " Call in command | |
33 command Flnum echo expand('<sflnum>') | |
34 call assert_equal(34, str2nr(trim(execute('Flnum')))) | |
35 delcommand Flnum | |
36 endfunc | |
37 | |
38 func Test_expand_sfile_and_stack() | |
39 call assert_match('test_expand_func\.vim$', s:sfile) | |
40 let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$' | |
41 call assert_match(expected , expand('<sfile>')) | |
42 call assert_match(expected , expand('<stack>')) | |
43 | |
44 " Call in script-local function | |
45 call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.<SNR>\d\+_expand_sfile$', s:expand_sfile()) | |
25 | 46 |
26 " Call in command | 47 " Call in command |
27 command Sfile echo expand('<sfile>') | 48 command Sfile echo expand('<sfile>') |
28 call assert_match('^function .*\.\.Test_expand_sfile$', trim(execute('Sfile'))) | 49 call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack$', trim(execute('Sfile'))) |
29 delcommand Sfile | 50 delcommand Sfile |
51 | |
52 " Use <stack> from sourced script. | |
53 let lines =<< trim END | |
54 let g:stack_value = expand('<stack>') | |
55 END | |
56 call writefile(lines, 'Xstack') | |
57 source Xstack | |
58 call assert_match('\<Xstack$', g:stack_value) | |
59 call delete('Xstack') | |
30 endfunc | 60 endfunc |
31 | 61 |
32 func Test_expand_slnum() | 62 func Test_expand_slnum() |
33 call assert_equal(4, s:slnum) | 63 call assert_equal(4, s:slnum) |
34 call assert_equal(2, str2nr(expand('<slnum>'))) | 64 call assert_equal(2, str2nr(expand('<slnum>'))) |
43 | 73 |
44 " Call in command | 74 " Call in command |
45 command Slnum echo expand('<slnum>') | 75 command Slnum echo expand('<slnum>') |
46 call assert_equal(14, str2nr(trim(execute('Slnum')))) | 76 call assert_equal(14, str2nr(trim(execute('Slnum')))) |
47 delcommand Slnum | 77 delcommand Slnum |
48 endfunc | |
49 | |
50 func Test_expand_sflnum() | |
51 call assert_equal(5, s:sflnum) | |
52 call assert_equal(52, str2nr(expand('<sflnum>'))) | |
53 | |
54 " Line-continuation | |
55 call assert_equal( | |
56 \ 55, | |
57 \ str2nr(expand('<sflnum>'))) | |
58 | |
59 " Call in script-local function | |
60 call assert_equal(16, s:expand_sflnum()) | |
61 | |
62 " Call in command | |
63 command Flnum echo expand('<sflnum>') | |
64 call assert_equal(64, str2nr(trim(execute('Flnum')))) | |
65 delcommand Flnum | |
66 endfunc | 78 endfunc |
67 | 79 |
68 func Test_expand() | 80 func Test_expand() |
69 new | 81 new |
70 call assert_equal("", expand('%:S')) | 82 call assert_equal("", expand('%:S')) |