comparison src/testdir/test_tagjump.vim @ 27974:495418c6cac8 v8.2.4512

patch 8.2.4512: the find_tags_in_file() function is much too long Commit: https://github.com/vim/vim/commit/df1bbea436636ac227d33dd79f77e07f4fffb028 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Mar 5 14:35:12 2022 +0000 patch 8.2.4512: the find_tags_in_file() function is much too long Problem: The find_tags_in_file() function is much too long. Solution: Refactor into multiple smaller functions. (Yegappan Lakshmanan, closes #9892)
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Mar 2022 15:45:03 +0100
parents b65a50d2fa4f
children c724906134a3
comparison
equal deleted inserted replaced
27973:af916df7c907 27974:495418c6cac8
228 call delete("Xtest.dir", "rf") 228 call delete("Xtest.dir", "rf")
229 %bwipe! 229 %bwipe!
230 endfunc 230 endfunc
231 231
232 " Tests for tag search with !_TAG_FILE_ENCODING. 232 " Tests for tag search with !_TAG_FILE_ENCODING.
233 " Depends on the test83-tags2 and test83-tags3 files.
234 func Test_tag_file_encoding() 233 func Test_tag_file_encoding()
235 if has('vms') 234 if has('vms')
236 throw 'Skipped: does not work on VMS' 235 throw 'Skipped: does not work on VMS'
237 endif 236 endif
238 237
260 call assert_equal('abcdefghijklmnopqrs', getline('.')) 259 call assert_equal('abcdefghijklmnopqrs', getline('.'))
261 close 260 close
262 261
263 " case2: 262 " case2:
264 new 263 new
265 set tags=test83-tags2 264 let content = ['!_TAG_FILE_ENCODING cp932 //',
265 \ "\x82`\x82a\x82b Xtags2.txt /\x82`\x82a\x82b"]
266 call writefile(content, 'Xtags')
267 set tags=Xtags
266 tag /.BC 268 tag /.BC
267 call assert_equal('Xtags2.txt', expand('%:t')) 269 call assert_equal('Xtags2.txt', expand('%:t'))
268 call assert_equal('ABC', getline('.')) 270 call assert_equal('ABC', getline('.'))
271 call delete('Xtags')
269 close 272 close
270 273
271 " case3: 274 " case3:
272 new 275 new
273 set tags=test83-tags3 276 let contents = [
277 \ "!_TAG_FILE_SORTED 1 //",
278 \ "!_TAG_FILE_ENCODING cp932 //"]
279 for i in range(1, 100)
280 call add(contents, 'abc' .. i
281 \ .. " Xtags3.txt /\x82`\x82a\x82b")
282 endfor
283 call writefile(contents, 'Xtags')
284 set tags=Xtags
274 tag abc50 285 tag abc50
275 call assert_equal('Xtags3.txt', expand('%:t')) 286 call assert_equal('Xtags3.txt', expand('%:t'))
276 call assert_equal('ABC', getline('.')) 287 call assert_equal('ABC', getline('.'))
288 call delete('Xtags')
277 close 289 close
278 290
279 set tags& 291 set tags&
280 let &encoding = save_enc 292 let &encoding = save_enc
281 call delete('Xtags1.txt') 293 call delete('Xtags1.txt')
322 \ "Xmain.c,64", 334 \ "Xmain.c,64",
323 \ "int main(int argc, char **argv)\x7fmain\x012,14", 335 \ "int main(int argc, char **argv)\x7fmain\x012,14",
324 \ ], 'Xtags2') 336 \ ], 'Xtags2')
325 tag main 337 tag main
326 call assert_equal(2, line('.')) 338 call assert_equal(2, line('.'))
339 call assert_fails('tag bar', 'E426:')
327 340
328 " corrupted tag line 341 " corrupted tag line
329 call writefile([ 342 call writefile([
330 \ "\x0c", 343 \ "\x0c",
331 \ "Xmain.c,8", 344 \ "Xmain.c,8",
345 call writefile([ 358 call writefile([
346 \ "\x0c", 359 \ "\x0c",
347 \ "Xmain.c,64", 360 \ "Xmain.c,64",
348 \ ";;;;\x7f1,0", 361 \ ";;;;\x7f1,0",
349 \ ], 'Xtags') 362 \ ], 'Xtags')
363 call assert_fails('tag foo', 'E431:')
364
365 " end of file after a CTRL-L line
366 call writefile([
367 \ "\x0c",
368 \ "Xmain.c,64",
369 \ "void foo() {}\x7ffoo\x011,0",
370 \ "\x0c",
371 \ ], 'Xtags')
372 call assert_fails('tag main', 'E426:')
373
374 " error in an included tags file
375 call writefile([
376 \ "\x0c",
377 \ "Xtags2,include"
378 \ ], 'Xtags')
379 call writefile([
380 \ "\x0c",
381 \ "Xmain.c,64",
382 \ "void foo() {}",
383 \ ], 'Xtags2')
350 call assert_fails('tag foo', 'E431:') 384 call assert_fails('tag foo', 'E431:')
351 385
352 call delete('Xtags') 386 call delete('Xtags')
353 call delete('Xtags2') 387 call delete('Xtags2')
354 call delete('Xmain.c') 388 call delete('Xmain.c')
1430 " tag name and file name are not separated by a tab 1464 " tag name and file name are not separated by a tab
1431 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", 1465 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
1432 \ "foo Xfile 1"], 'Xtags') 1466 \ "foo Xfile 1"], 'Xtags')
1433 call assert_fails('tag foo', 'E431:') 1467 call assert_fails('tag foo', 'E431:')
1434 1468
1469 " file name and search pattern are not separated by a tab
1470 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
1471 \ "foo\tXfile 1;"], 'Xtags')
1472 call assert_fails('tag foo', 'E431:')
1473
1435 call delete('Xtags') 1474 call delete('Xtags')
1436 call delete('Xfile') 1475 call delete('Xfile')
1437 set tags& 1476 set tags&
1438 endfunc 1477 endfunc
1439 1478