annotate src/testdir/test_taglist.vim @ 18478:94223687df0e

Added tag v8.1.2233 for changeset e93cab5d0f0f27fad7882f1f412927df055b090d
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Oct 2019 04:30:05 +0100
parents 8a2fb21c23c0
children 8645b73b3645
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14232
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
1 " test taglist(), tagfiles() functions and :tags command
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_taglist()
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 call writefile([
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 \ "FFoo\tXfoo\t1",
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 \ "FBar\tXfoo\t2",
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 \ "BFoo\tXbar\t1",
15808
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
8 \ "BBar\tXbar\t2",
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
9 \ "Kindly\tXbar\t3;\"\tv\tfile:",
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
10 \ "Command\tXbar\tcall cursor(3, 4)|;\"\td",
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 \ ], 'Xtags')
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 set tags=Xtags
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 split Xtext
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo"), {i, v -> v.name}))
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17093
diff changeset
16 call assert_equal(['FFoo', 'BFoo'], map("Foo"->taglist("Xtext"), {i, v -> v.name}))
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
15808
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
20 let kind = taglist("Kindly")
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
21 call assert_equal(1, len(kind))
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
22 call assert_equal('v', kind[0]['kind'])
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
23 call assert_equal('3', kind[0]['cmd'])
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
24 call assert_equal(1, kind[0]['static'])
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
25 call assert_equal('Xbar', kind[0]['filename'])
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
26
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
27 let cmd = taglist("Command")
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
28 call assert_equal(1, len(cmd))
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
29 call assert_equal('d', cmd[0]['kind'])
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
30 call assert_equal('call cursor(3, 4)', cmd[0]['cmd'])
37d31fc37a5a patch 8.1.0911: tag line with Ex command cannot have extra fields
Bram Moolenaar <Bram@vim.org>
parents: 14232
diff changeset
31
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call delete('Xtags')
17093
5cda6165a5c1 patch 8.1.1546: in some tests 'tags' is set but not restored
Bram Moolenaar <Bram@vim.org>
parents: 16190
diff changeset
33 set tags&
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 bwipe
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 endfunc
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
11329
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
37 func Test_taglist_native_etags()
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
38 if !has('emacs_tags')
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
39 return
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
40 endif
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
41 call writefile([
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
42 \ "\x0c",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
43 \ "src/os_unix.c,13491",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
44 \ "set_signals(\x7f1335,32699",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
45 \ "reset_signals(\x7f1407,34136",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
46 \ ], 'Xtags')
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
47
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
48 set tags=Xtags
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
49
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
50 call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
51 \ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
52
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
53 call delete('Xtags')
17093
5cda6165a5c1 patch 8.1.1546: in some tests 'tags' is set but not restored
Bram Moolenaar <Bram@vim.org>
parents: 16190
diff changeset
54 set tags&
11329
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
55 endfunc
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
56
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
57 func Test_taglist_ctags_etags()
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
58 if !has('emacs_tags')
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
59 return
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
60 endif
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
61 call writefile([
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
62 \ "\x0c",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
63 \ "src/os_unix.c,13491",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
64 \ "set_signals(void)\x7fset_signals\x011335,32699",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
65 \ "reset_signals(void)\x7freset_signals\x011407,34136",
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
66 \ ], 'Xtags')
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
67
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
68 set tags=Xtags
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
69
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
70 call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
71 \ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
72
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
73 call delete('Xtags')
17093
5cda6165a5c1 patch 8.1.1546: in some tests 'tags' is set but not restored
Bram Moolenaar <Bram@vim.org>
parents: 16190
diff changeset
74 set tags&
11329
c7ba89661c39 patch 8.0.0550: cannot parse some etags format tags file
Christian Brabandt <cb@256bit.org>
parents: 11225
diff changeset
75 endfunc
13068
63fdea6e9c6c patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents: 11329
diff changeset
76
63fdea6e9c6c patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents: 11329
diff changeset
77 func Test_tags_too_long()
63fdea6e9c6c patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents: 11329
diff changeset
78 call assert_fails('tag ' . repeat('x', 1020), 'E426')
63fdea6e9c6c patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents: 11329
diff changeset
79 tags
63fdea6e9c6c patch 8.0.1409: buffer overflow in :tags command
Christian Brabandt <cb@256bit.org>
parents: 11329
diff changeset
80 endfunc
14232
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
81
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
82 func Test_tagfiles()
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
83 call assert_equal([], tagfiles())
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
84
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
85 call writefile(["FFoo\tXfoo\t1"], 'Xtags1')
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
86 call writefile(["FBar\tXbar\t1"], 'Xtags2')
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
87 set tags=Xtags1,Xtags2
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
88 call assert_equal(['Xtags1', 'Xtags2'], tagfiles())
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
89
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
90 help
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
91 let tf = tagfiles()
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
92 call assert_equal(1, len(tf))
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
93 call assert_equal(fnamemodify(expand('$VIMRUNTIME/doc/tags'), ':p:gs?\\?/?'),
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
94 \ fnamemodify(tf[0], ':p:gs?\\?/?'))
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
95 helpclose
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
96 call assert_equal(['Xtags1', 'Xtags2'], tagfiles())
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
97 set tags&
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
98 call assert_equal([], tagfiles())
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
99
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
100 call delete('Xtags1')
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
101 call delete('Xtags2')
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
102 bd
4afe2386aae8 patch 8.1.0133: tagfiles() can have duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13068
diff changeset
103 endfunc
16190
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
104
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
105 " For historical reasons we support a tags file where the last line is missing
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
106 " the newline.
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
107 func Test_tagsfile_without_trailing_newline()
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
108 call writefile(["Foo\tfoo\t1"], 'Xtags', 'b')
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
109 set tags=Xtags
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
110
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
111 let tl = taglist('.*')
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
112 call assert_equal(1, len(tl))
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
113 call assert_equal('Foo', tl[0].name)
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
114
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
115 call delete('Xtags')
17093
5cda6165a5c1 patch 8.1.1546: in some tests 'tags' is set but not restored
Bram Moolenaar <Bram@vim.org>
parents: 16190
diff changeset
116 set tags&
16190
d863beec391a patch 8.1.1100: tag file without trailing newline no longer works
Bram Moolenaar <Bram@vim.org>
parents: 15808
diff changeset
117 endfunc