Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_tagjump.vim +++ b/src/testdir/test_tagjump.vim @@ -230,7 +230,6 @@ func Test_tag_symbolic() endfunc " Tests for tag search with !_TAG_FILE_ENCODING. -" Depends on the test83-tags2 and test83-tags3 files. func Test_tag_file_encoding() if has('vms') throw 'Skipped: does not work on VMS' @@ -262,18 +261,31 @@ func Test_tag_file_encoding() " case2: new - set tags=test83-tags2 + let content = ['!_TAG_FILE_ENCODING cp932 //', + \ "\x82`\x82a\x82b Xtags2.txt /\x82`\x82a\x82b"] + call writefile(content, 'Xtags') + set tags=Xtags tag /.BC call assert_equal('Xtags2.txt', expand('%:t')) call assert_equal('ABC', getline('.')) + call delete('Xtags') close " case3: new - set tags=test83-tags3 + let contents = [ + \ "!_TAG_FILE_SORTED 1 //", + \ "!_TAG_FILE_ENCODING cp932 //"] + for i in range(1, 100) + call add(contents, 'abc' .. i + \ .. " Xtags3.txt /\x82`\x82a\x82b") + endfor + call writefile(contents, 'Xtags') + set tags=Xtags tag abc50 call assert_equal('Xtags3.txt', expand('%:t')) call assert_equal('ABC', getline('.')) + call delete('Xtags') close set tags& @@ -324,6 +336,7 @@ func Test_tagjump_etags() \ ], 'Xtags2') tag main call assert_equal(2, line('.')) + call assert_fails('tag bar', 'E426:') " corrupted tag line call writefile([ @@ -349,6 +362,27 @@ func Test_tagjump_etags() \ ], 'Xtags') call assert_fails('tag foo', 'E431:') + " end of file after a CTRL-L line + call writefile([ + \ "\x0c", + \ "Xmain.c,64", + \ "void foo() {}\x7ffoo\x011,0", + \ "\x0c", + \ ], 'Xtags') + call assert_fails('tag main', 'E426:') + + " error in an included tags file + call writefile([ + \ "\x0c", + \ "Xtags2,include" + \ ], 'Xtags') + call writefile([ + \ "\x0c", + \ "Xmain.c,64", + \ "void foo() {}", + \ ], 'Xtags2') + call assert_fails('tag foo', 'E431:') + call delete('Xtags') call delete('Xtags2') call delete('Xmain.c') @@ -1432,6 +1466,11 @@ func Test_tagfile_errors() \ "foo Xfile 1"], 'Xtags') call assert_fails('tag foo', 'E431:') + " file name and search pattern are not separated by a tab + call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", + \ "foo\tXfile 1;"], 'Xtags') + call assert_fails('tag foo', 'E431:') + call delete('Xtags') call delete('Xfile') set tags&