Mercurial > vim
annotate src/testdir/test_tagfunc.vim @ 20918:a253e5fc58d1
Added tag v8.2.1010 for changeset 5c6a6b5a33308a5e803f5289ea6c15c67d3f8db3
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 19 Jun 2020 17:30:04 +0200 |
parents | 8645b73b3645 |
children | 6a4806e326dd |
rev | line source |
---|---|
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test 'tagfunc' |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 func TagFunc(pat, flag, info) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 let g:tagfunc_args = [a:pat, a:flag, a:info] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 let tags = [] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 for num in range(1,10) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 let tags += [{ |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 \ 'cmd': '2', 'name': 'nothing'.num, 'kind': 'm', |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 \ 'filename': 'Xfile1', 'user_data': 'somedata'.num, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 \}] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 endfor |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 return tags |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 func Test_tagfunc() |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 set tagfunc=TagFunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 new Xfile1 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 call setline(1, ['empty', 'one()', 'empty']) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 write |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 call assert_equal({'cmd': '2', 'static': 0, |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 \ 'name': 'nothing2', 'user_data': 'somedata2', |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 \ 'kind': 'm', 'filename': 'Xfile1'}, taglist('.')[1]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 call settagstack(win_getid(), {'items': []}) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 tag arbitrary |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 call assert_equal('arbitrary', g:tagfunc_args[0]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 call assert_equal('', g:tagfunc_args[1]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 call assert_equal('somedata1', gettagstack().items[0].user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 5tag arbitrary |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 call assert_equal('arbitrary', g:tagfunc_args[0]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 call assert_equal('', g:tagfunc_args[1]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 call assert_equal('somedata5', gettagstack().items[1].user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 pop |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 tag |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 call assert_equal('arbitrary', g:tagfunc_args[0]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 call assert_equal('', g:tagfunc_args[1]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 call assert_equal('somedata5', gettagstack().items[1].user_data) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 let g:tagfunc_args=[] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 execute "normal! \<c-]>" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 call assert_equal('one', g:tagfunc_args[0]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 call assert_equal('c', g:tagfunc_args[1]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 set cpt=t |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 let g:tagfunc_args=[] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 execute "normal! i\<c-n>\<c-y>" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 call assert_equal('ci', g:tagfunc_args[1]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 call assert_equal('nothing1', getline('.')[0:7]) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 func BadTagFunc1(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 return 0 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 func BadTagFunc2(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 return [1] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 func BadTagFunc3(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 return [{'name': 'foo'}] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 for &tagfunc in ['BadTagFunc1', 'BadTagFunc2', 'BadTagFunc3'] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 try |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 tag nothing |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 call assert_false(1, 'tag command should have failed') |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 catch |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 call assert_exception('E987:') |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 endtry |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 exe 'delf' &tagfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 endfor |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 func NullTagFunc(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 return v:null |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 set tags= tfu=NullTagFunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 call assert_fails('tag nothing', 'E426') |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 delf NullTagFunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 bwipe! |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 set tags& tfu& cpt& |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 call delete('Xfile1') |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 |
19055
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
84 " Test for modifying the tag stack from a tag function and jumping to a tag |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
85 " from a tag function |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
86 func Test_tagfunc_settagstack() |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
87 func Mytagfunc1(pat, flags, info) |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
88 call settagstack(1, {'tagname' : 'mytag', 'from' : [0, 10, 1, 0]}) |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
89 return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}] |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
90 endfunc |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
91 set tagfunc=Mytagfunc1 |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
92 call writefile([''], 'Xtest') |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
93 call assert_fails('tag xyz', 'E986:') |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
94 |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
95 func Mytagfunc2(pat, flags, info) |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
96 tag test_tag |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
97 return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}] |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
98 endfunc |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
99 set tagfunc=Mytagfunc2 |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
100 call assert_fails('tag xyz', 'E986:') |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
101 |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
102 call delete('Xtest') |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
103 set tagfunc& |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
104 delfunc Mytagfunc1 |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
105 delfunc Mytagfunc2 |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
106 endfunc |
8645b73b3645
patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
107 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 " vim: shiftwidth=2 sts=2 expandtab |