comparison src/testdir/test_taglist.vim @ 19055:8645b73b3645 v8.2.0088

patch 8.2.0088: insufficient tests for tags; bug in using extra tag field Commit: https://github.com/vim/vim/commit/830c1afc9d2cd5819a05c71d4e0b1f748a8c0519 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 5 20:35:44 2020 +0100 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field Problem: Insufficient tests for tags; bug in using extra tag field when using an ex command to position the cursor. Solution: Fix the bug, add more tests. (Yegappan Lakshmanan, closes #5439)
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jan 2020 20:45:05 +0100
parents 8a2fb21c23c0
children 5ce724c60c4c
comparison
equal deleted inserted replaced
19054:ebee9e4dac40 19055:8645b73b3645
113 call assert_equal('Foo', tl[0].name) 113 call assert_equal('Foo', tl[0].name)
114 114
115 call delete('Xtags') 115 call delete('Xtags')
116 set tags& 116 set tags&
117 endfunc 117 endfunc
118
119 " Test for ignoring comments in a tags file
120 func Test_tagfile_ignore_comments()
121 call writefile([
122 \ "!_TAG_PROGRAM_NAME /Test tags generator/",
123 \ "FBar\tXfoo\t2" .. ';"' .. "\textrafield\tf",
124 \ "!_TAG_FILE_FORMAT 2 /extended format/",
125 \ ], 'Xtags')
126 set tags=Xtags
127
128 let l = taglist('.*')
129 call assert_equal(1, len(l))
130 call assert_equal('FBar', l[0].name)
131
132 set tags&
133 call delete('Xtags')
134 endfunc
135
136 " Test for using an excmd in a tags file to position the cursor (instead of a
137 " search pattern or a line number)
138 func Test_tagfile_excmd()
139 call writefile([
140 \ "vFoo\tXfoo\tcall cursor(3, 4)" .. '|;"' .. "\tv",
141 \ ], 'Xtags')
142 set tags=Xtags
143
144 let l = taglist('.*')
145 call assert_equal([{
146 \ 'cmd' : 'call cursor(3, 4)',
147 \ 'static' : 0,
148 \ 'name' : 'vFoo',
149 \ 'kind' : 'v',
150 \ 'filename' : 'Xfoo'}], l)
151
152 set tags&
153 call delete('Xtags')
154 endfunc
155
156 " Test for duplicate fields in a tag in a tags file
157 func Test_duplicate_field()
158 call writefile([
159 \ "vFoo\tXfoo\t4" .. ';"' .. "\ttypename:int\ttypename:int\tv",
160 \ ], 'Xtags')
161 set tags=Xtags
162
163 let l = taglist('.*')
164 call assert_equal([{
165 \ 'cmd' : '4',
166 \ 'static' : 0,
167 \ 'name' : 'vFoo',
168 \ 'kind' : 'v',
169 \ 'typename' : 'int',
170 \ 'filename' : 'Xfoo'}], l)
171
172 set tags&
173 call delete('Xtags')
174 endfunc
175
176 " Test for tag address with ;
177 func Test_tag_addr_with_semicolon()
178 call writefile([
179 \ "Func1\tXfoo\t6;/^Func1/" .. ';"' .. "\tf"
180 \ ], 'Xtags')
181 set tags=Xtags
182
183 let l = taglist('.*')
184 call assert_equal([{
185 \ 'cmd' : '6;/^Func1/',
186 \ 'static' : 0,
187 \ 'name' : 'Func1',
188 \ 'kind' : 'f',
189 \ 'filename' : 'Xfoo'}], l)
190
191 set tags&
192 call delete('Xtags')
193 endfunc
194
195 " Test for format error in a tags file
196 func Test_format_error()
197 call writefile(['vFoo-Xfoo-4'], 'Xtags')
198 set tags=Xtags
199
200 let caught_exception = v:false
201 try
202 let l = taglist('.*')
203 catch /E431:/
204 " test succeeded
205 let caught_exception = v:true
206 catch
207 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
208 endtry
209 call assert_true(caught_exception)
210
211 set tags&
212 call delete('Xtags')
213 endfunc