Mercurial > vim
comparison src/testdir/test_tagjump.vim @ 30865:c8ebe35b2475 v9.0.0767
patch 9.0.0767: too many delete() calls in tests
Commit: https://github.com/vim/vim/commit/c4860bdd2832feb7ab054c6dc14f68abe24c2373
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 15 20:52:26 2022 +0100
patch 9.0.0767: too many delete() calls in tests
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Oct 2022 22:00:04 +0200 |
parents | 13b02c1ea0f7 |
children | 97bb0811cfd4 |
comparison
equal
deleted
inserted
replaced
30864:51906709cb7a | 30865:c8ebe35b2475 |
---|---|
18 set tags=Xpttags | 18 set tags=Xpttags |
19 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 19 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
20 \ "one\tXptfile\t1", | 20 \ "one\tXptfile\t1", |
21 \ "three\tXptfile\t3", | 21 \ "three\tXptfile\t3", |
22 \ "two\tXptfile\t2"], | 22 \ "two\tXptfile\t2"], |
23 \ 'Xpttags') | 23 \ 'Xpttags', 'D') |
24 call writefile(['one', 'two', 'three'], 'Xptfile') | 24 call writefile(['one', 'two', 'three'], 'Xptfile', 'D') |
25 | 25 |
26 %bw! | 26 %bw! |
27 ptjump two | 27 ptjump two |
28 call assert_equal(2, winnr()) | 28 call assert_equal(2, winnr()) |
29 wincmd p | 29 wincmd p |
46 exe "normal 3G5\<C-W>\<C-G>}" | 46 exe "normal 3G5\<C-W>\<C-G>}" |
47 wincmd p | 47 wincmd p |
48 call assert_equal(5, winheight(0)) | 48 call assert_equal(5, winheight(0)) |
49 close | 49 close |
50 | 50 |
51 call delete('Xpttags') | |
52 call delete('Xptfile') | |
53 set tags& | 51 set tags& |
54 endfunc | 52 endfunc |
55 | 53 |
56 func Test_cancel_ptjump() | 54 func Test_cancel_ptjump() |
57 CheckFeature quickfix | 55 CheckFeature quickfix |
58 | 56 |
59 set tags=Xtags | 57 set tags=Xtags |
60 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 58 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
61 \ "word\tfile1\tcmd1", | 59 \ "word\tfile1\tcmd1", |
62 \ "word\tfile2\tcmd2"], | 60 \ "word\tfile2\tcmd2"], |
63 \ 'Xtags') | 61 \ 'Xtags', 'D') |
64 | 62 |
65 only! | 63 only! |
66 call feedkeys(":ptjump word\<CR>\<CR>", "xt") | 64 call feedkeys(":ptjump word\<CR>\<CR>", "xt") |
67 help | 65 help |
68 call assert_equal(2, winnr('$')) | 66 call assert_equal(2, winnr('$')) |
69 | 67 |
70 call delete('Xtags') | |
71 set tags& | 68 set tags& |
72 quit | 69 quit |
73 endfunc | 70 endfunc |
74 | 71 |
75 func Test_static_tagjump() | 72 func Test_static_tagjump() |
76 set tags=Xtjtags | 73 set tags=Xtjtags |
77 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 74 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
78 \ "one\tXtjfile1\t/^one/;\"\tf\tfile:\tsignature:(void)", | 75 \ "one\tXtjfile1\t/^one/;\"\tf\tfile:\tsignature:(void)", |
79 \ "word\tXtjfile2\tcmd2"], | 76 \ "word\tXtjfile2\tcmd2"], |
80 \ 'Xtjtags') | 77 \ 'Xtjtags', 'D') |
81 new Xtjfile1 | 78 new Xtjfile1 |
82 call setline(1, ['empty', 'one()', 'empty']) | 79 call setline(1, ['empty', 'one()', 'empty']) |
83 write | 80 write |
84 tag one | 81 tag one |
85 call assert_equal(2, line('.')) | 82 call assert_equal(2, line('.')) |
86 | 83 |
87 bwipe! | 84 bwipe! |
88 set tags& | 85 set tags& |
89 call delete('Xtjtags') | |
90 call delete('Xtjfile1') | 86 call delete('Xtjfile1') |
91 endfunc | 87 endfunc |
92 | 88 |
93 func Test_duplicate_tagjump() | 89 func Test_duplicate_tagjump() |
94 set tags=Xdttags | 90 set tags=Xdttags |
95 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 91 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
96 \ "thesame\tXdtfile1\t1;\"\td\tfile:", | 92 \ "thesame\tXdtfile1\t1;\"\td\tfile:", |
97 \ "thesame\tXdtfile1\t2;\"\td\tfile:", | 93 \ "thesame\tXdtfile1\t2;\"\td\tfile:", |
98 \ "thesame\tXdtfile1\t3;\"\td\tfile:", | 94 \ "thesame\tXdtfile1\t3;\"\td\tfile:", |
99 \ ], | 95 \ ], |
100 \ 'Xdttags') | 96 \ 'Xdttags', 'D') |
101 new Xdtfile1 | 97 new Xdtfile1 |
102 call setline(1, ['thesame one', 'thesame two', 'thesame three']) | 98 call setline(1, ['thesame one', 'thesame two', 'thesame three']) |
103 write | 99 write |
104 tag thesame | 100 tag thesame |
105 call assert_equal(1, line('.')) | 101 call assert_equal(1, line('.')) |
108 tnext | 104 tnext |
109 call assert_equal(3, line('.')) | 105 call assert_equal(3, line('.')) |
110 | 106 |
111 bwipe! | 107 bwipe! |
112 set tags& | 108 set tags& |
113 call delete('Xdttags') | |
114 call delete('Xdtfile1') | 109 call delete('Xdtfile1') |
115 endfunc | 110 endfunc |
116 | 111 |
117 func Test_tagjump_switchbuf() | 112 func Test_tagjump_switchbuf() |
118 CheckFeature quickfix | 113 CheckFeature quickfix |
119 | 114 |
120 set tags=Xswtags | 115 set tags=Xswtags |
121 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 116 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
122 \ "second\tXsbfile1\t2", | 117 \ "second\tXsbfile1\t2", |
123 \ "third\tXsbfile1\t3",], | 118 \ "third\tXsbfile1\t3",], |
124 \ 'Xswtags') | 119 \ 'Xswtags', 'D') |
125 call writefile(['first', 'second', 'third'], 'Xsbfile1') | 120 call writefile(['first', 'second', 'third'], 'Xsbfile1', 'D') |
126 | 121 |
127 enew | only | 122 enew | only |
128 set switchbuf= | 123 set switchbuf= |
129 stag second | 124 stag second |
130 call assert_equal(2, winnr('$')) | 125 call assert_equal(2, winnr('$')) |
151 call assert_equal(2, tabpagenr('$')) | 146 call assert_equal(2, tabpagenr('$')) |
152 call assert_equal(3, line('.')) | 147 call assert_equal(3, line('.')) |
153 | 148 |
154 tabclose! | 149 tabclose! |
155 enew | only | 150 enew | only |
156 call delete('Xsbfile1') | |
157 call delete('Xswtags') | |
158 set tags& | 151 set tags& |
159 set switchbuf&vim | 152 set switchbuf&vim |
160 endfunc | 153 endfunc |
161 | 154 |
162 " Tests for [ CTRL-I and CTRL-W CTRL-I commands | 155 " Tests for [ CTRL-I and CTRL-W CTRL-I commands |
166 \ "/* test text test tex start here", | 159 \ "/* test text test tex start here", |
167 \ " some text", | 160 \ " some text", |
168 \ " test text", | 161 \ " test text", |
169 \ " start OK if found this line", | 162 \ " start OK if found this line", |
170 \ " start found wrong line", | 163 \ " start found wrong line", |
171 \ "test text"], 'Xtestfile') | 164 \ "test text"], 'Xtestfile', 'D') |
172 call writefile(["/* test text test tex start here", | 165 call writefile(["/* test text test tex start here", |
173 \ " some text", | 166 \ " some text", |
174 \ " test text", | 167 \ " test text", |
175 \ " start OK if found this line", | 168 \ " start OK if found this line", |
176 \ " start found wrong line", | 169 \ " start found wrong line", |
177 \ "test text"], 'Xinclude') | 170 \ "test text"], 'Xinclude', 'D') |
178 new Xtestfile | 171 new Xtestfile |
179 call cursor(1,1) | 172 call cursor(1,1) |
180 call search("start") | 173 call search("start") |
181 exe "normal! 5[\<C-I>" | 174 exe "normal! 5[\<C-I>" |
182 call assert_equal(" start OK if found this line", getline('.')) | 175 call assert_equal(" start OK if found this line", getline('.')) |
187 | 180 |
188 " invalid tag search pattern | 181 " invalid tag search pattern |
189 call assert_fails('tag /\%(/', 'E426:') | 182 call assert_fails('tag /\%(/', 'E426:') |
190 | 183 |
191 enew! | only | 184 enew! | only |
192 call delete('Xtestfile') | |
193 call delete('Xinclude') | |
194 endfunction | 185 endfunction |
195 | 186 |
196 " Test for jumping to a tag with 'hidden' set, with symbolic link in path of | 187 " Test for jumping to a tag with 'hidden' set, with symbolic link in path of |
197 " tag. This only works for Unix, because of the symbolic link. | 188 " tag. This only works for Unix, because of the symbolic link. |
198 func Test_tag_symbolic() | 189 func Test_tag_symbolic() |
203 call system("ln -s . Xtest.dir") | 194 call system("ln -s . Xtest.dir") |
204 " Create a tags file with the current directory name inserted. | 195 " Create a tags file with the current directory name inserted. |
205 call writefile([ | 196 call writefile([ |
206 \ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/", | 197 \ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/", |
207 \ '', | 198 \ '', |
208 \ ], 'Xsymtags') | 199 \ ], 'Xsymtags', 'D') |
209 call writefile(['#define SECTION_OFF 3', | 200 call writefile(['#define SECTION_OFF 3', |
210 \ '#define NUM_SECTIONS 3'], 'Xtest.c') | 201 \ '#define NUM_SECTIONS 3'], 'Xtest.c', 'D') |
211 | 202 |
212 " Try jumping to a tag, but with a path that contains a symbolic link. When | 203 " Try jumping to a tag, but with a path that contains a symbolic link. When |
213 " wrong, this will give the ATTENTION message. The next space will then be | 204 " wrong, this will give the ATTENTION message. The next space will then be |
214 " eaten by hit-return, instead of moving the cursor to 'd'. | 205 " eaten by hit-return, instead of moving the cursor to 'd'. |
215 set tags=Xsymtags | 206 set tags=Xsymtags |
221 call assert_equal(2, col('.')) | 212 call assert_equal(2, col('.')) |
222 | 213 |
223 set hidden& | 214 set hidden& |
224 set tags& | 215 set tags& |
225 enew! | 216 enew! |
226 call delete('Xsymtags') | |
227 call delete('Xtest.c') | |
228 call delete("Xtest.dir", "rf") | 217 call delete("Xtest.dir", "rf") |
229 %bwipe! | 218 %bwipe! |
230 endfunc | 219 endfunc |
231 | 220 |
232 " Tests for tag search with !_TAG_FILE_ENCODING. | 221 " Tests for tag search with !_TAG_FILE_ENCODING. |
241 | 230 |
242 let save_enc = &encoding | 231 let save_enc = &encoding |
243 set encoding=utf8 | 232 set encoding=utf8 |
244 | 233 |
245 let content = ['text for tags1', 'abcdefghijklmnopqrs'] | 234 let content = ['text for tags1', 'abcdefghijklmnopqrs'] |
246 call writefile(content, 'Xtags1.txt') | 235 call writefile(content, 'Xtags1.txt', 'D') |
247 let content = ['text for tags2', 'ABC'] | 236 let content = ['text for tags2', 'ABC'] |
248 call writefile(content, 'Xtags2.txt') | 237 call writefile(content, 'Xtags2.txt', 'D') |
249 let content = ['text for tags3', 'ABC'] | 238 let content = ['text for tags3', 'ABC'] |
250 call writefile(content, 'Xtags3.txt') | 239 call writefile(content, 'Xtags3.txt', 'D') |
251 let content = ['!_TAG_FILE_ENCODING utf-8 //', 'abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs'] | 240 let content = ['!_TAG_FILE_ENCODING utf-8 //', 'abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs'] |
252 call writefile(content, 'Xtags1') | 241 call writefile(content, 'Xtags1', 'D') |
253 | 242 |
254 " case1: | 243 " case1: |
255 new | 244 new |
256 set tags=Xtags1 | 245 set tags=Xtags1 |
257 tag abcdefghijklmnopqrs | 246 tag abcdefghijklmnopqrs |
278 \ "!_TAG_FILE_ENCODING cp932 //"] | 267 \ "!_TAG_FILE_ENCODING cp932 //"] |
279 for i in range(1, 100) | 268 for i in range(1, 100) |
280 call add(contents, 'abc' .. i | 269 call add(contents, 'abc' .. i |
281 \ .. " Xtags3.txt /\x82`\x82a\x82b") | 270 \ .. " Xtags3.txt /\x82`\x82a\x82b") |
282 endfor | 271 endfor |
283 call writefile(contents, 'Xenctags') | 272 call writefile(contents, 'Xenctags', 'D') |
284 set tags=Xenctags | 273 set tags=Xenctags |
285 tag abc50 | 274 tag abc50 |
286 call assert_equal('Xtags3.txt', expand('%:t')) | 275 call assert_equal('Xtags3.txt', expand('%:t')) |
287 call assert_equal('ABC', getline('.')) | 276 call assert_equal('ABC', getline('.')) |
288 call delete('Xenctags') | |
289 close | 277 close |
290 | 278 |
291 set tags& | 279 set tags& |
292 let &encoding = save_enc | 280 let &encoding = save_enc |
293 call delete('Xtags1.txt') | |
294 call delete('Xtags2.txt') | |
295 call delete('Xtags3.txt') | |
296 call delete('Xtags1') | |
297 endfunc | 281 endfunc |
298 | 282 |
299 " Test for emacs-style tags file (TAGS) | 283 " Test for emacs-style tags file (TAGS) |
300 func Test_tagjump_etags() | 284 func Test_tagjump_etags() |
301 CheckFeature emacs_tags | 285 CheckFeature emacs_tags |
305 \ "int main(int argc, char **argv)", | 289 \ "int main(int argc, char **argv)", |
306 \ "{", | 290 \ "{", |
307 \ "\tfoo();", | 291 \ "\tfoo();", |
308 \ "\treturn 0;", | 292 \ "\treturn 0;", |
309 \ "}", | 293 \ "}", |
310 \ ], 'Xmain.c') | 294 \ ], 'Xmain.c', 'D') |
311 | 295 |
312 call writefile([ | 296 call writefile([ |
313 \ "\x0c", | 297 \ "\x0c", |
314 \ "Xmain.c,64", | 298 \ "Xmain.c,64", |
315 \ "void foo() {}\x7ffoo\x011,0", | 299 \ "void foo() {}\x7ffoo\x011,0", |
316 \ "int main(int argc, char **argv)\x7fmain\x012,14", | 300 \ "int main(int argc, char **argv)\x7fmain\x012,14", |
317 \ ], 'Xtetags') | 301 \ ], 'Xtetags', 'D') |
318 set tags=Xtetags | 302 set tags=Xtetags |
319 ta foo | 303 ta foo |
320 call assert_equal('void foo() {}', getline('.')) | 304 call assert_equal('void foo() {}', getline('.')) |
321 | 305 |
322 " Test for including another tags file | 306 " Test for including another tags file |
331 \ ], 'Xtetags') | 315 \ ], 'Xtetags') |
332 call writefile([ | 316 call writefile([ |
333 \ "\x0c", | 317 \ "\x0c", |
334 \ "Xmain.c,64", | 318 \ "Xmain.c,64", |
335 \ "int main(int argc, char **argv)\x7fmain\x012,14", | 319 \ "int main(int argc, char **argv)\x7fmain\x012,14", |
336 \ ], 'Xtags2') | 320 \ ], 'Xtags2', 'D') |
337 tag main | 321 tag main |
338 call assert_equal(2, line('.')) | 322 call assert_equal(2, line('.')) |
339 call assert_fails('tag bar', 'E426:') | 323 call assert_fails('tag bar', 'E426:') |
340 | 324 |
341 " corrupted tag line | 325 " corrupted tag line |
381 \ "Xmain.c,64", | 365 \ "Xmain.c,64", |
382 \ "void foo() {}", | 366 \ "void foo() {}", |
383 \ ], 'Xtags2') | 367 \ ], 'Xtags2') |
384 call assert_fails('tag foo', 'E431:') | 368 call assert_fails('tag foo', 'E431:') |
385 | 369 |
386 call delete('Xtetags') | |
387 call delete('Xtags2') | |
388 call delete('Xmain.c') | |
389 set tags& | 370 set tags& |
390 bwipe! | 371 bwipe! |
391 endfunc | 372 endfunc |
392 | 373 |
393 " Test for getting and modifying the tag stack | 374 " Test for getting and modifying the tag stack |
394 func Test_getsettagstack() | 375 func Test_getsettagstack() |
395 call writefile(['line1', 'line2', 'line3'], 'Xstsfile1') | 376 call writefile(['line1', 'line2', 'line3'], 'Xstsfile1', 'D') |
396 call writefile(['line1', 'line2', 'line3'], 'Xstsfile2') | 377 call writefile(['line1', 'line2', 'line3'], 'Xstsfile2', 'D') |
397 call writefile(['line1', 'line2', 'line3'], 'Xstsfile3') | 378 call writefile(['line1', 'line2', 'line3'], 'Xstsfile3', 'D') |
398 | 379 |
399 enew | only | 380 enew | only |
400 call settagstack(1, {'items' : []}) | 381 call settagstack(1, {'items' : []}) |
401 call assert_equal(0, gettagstack(1).length) | 382 call assert_equal(0, gettagstack(1).length) |
402 call assert_equal([], 1->gettagstack().items) | 383 call assert_equal([], 1->gettagstack().items) |
412 set tags=Xtsttags | 393 set tags=Xtsttags |
413 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 394 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
414 \ "one\tXstsfile1\t1", | 395 \ "one\tXstsfile1\t1", |
415 \ "three\tXstsfile3\t3", | 396 \ "three\tXstsfile3\t3", |
416 \ "two\tXstsfile2\t2"], | 397 \ "two\tXstsfile2\t2"], |
417 \ 'Xtsttags') | 398 \ 'Xtsttags', 'D') |
418 | 399 |
419 let stk = [] | 400 let stk = [] |
420 call add(stk, {'bufnr' : bufnr('%'), 'tagname' : 'one', | 401 call add(stk, {'bufnr' : bufnr('%'), 'tagname' : 'one', |
421 \ 'from' : [bufnr('%'), line('.'), col('.'), 0], 'matchnr' : 1}) | 402 \ 'from' : [bufnr('%'), line('.'), col('.'), 0], 'matchnr' : 1}) |
422 tag one | 403 tag one |
513 call assert_fails('call gettagstack()', 'E342:') | 494 call assert_fails('call gettagstack()', 'E342:') |
514 call test_alloc_fail(GetAllocId('tagstack_details'), 0, 0) | 495 call test_alloc_fail(GetAllocId('tagstack_details'), 0, 0) |
515 call assert_fails('call gettagstack()', 'E342:') | 496 call assert_fails('call gettagstack()', 'E342:') |
516 | 497 |
517 call settagstack(1, {'items' : []}) | 498 call settagstack(1, {'items' : []}) |
518 call delete('Xstsfile1') | |
519 call delete('Xstsfile2') | |
520 call delete('Xstsfile3') | |
521 call delete('Xtsttags') | |
522 set tags& | 499 set tags& |
523 endfunc | 500 endfunc |
524 | 501 |
525 func Test_tag_with_count() | 502 func Test_tag_with_count() |
526 call writefile([ | 503 call writefile([ |
527 \ 'test Xtest.h /^void test();$/;" p typeref:typename:void signature:()', | 504 \ 'test Xtest.h /^void test();$/;" p typeref:typename:void signature:()', |
528 \ ], 'Xtags') | 505 \ ], 'Xtags', 'D') |
529 call writefile([ | 506 call writefile([ |
530 \ 'main Xtest.c /^int main()$/;" f typeref:typename:int signature:()', | 507 \ 'main Xtest.c /^int main()$/;" f typeref:typename:int signature:()', |
531 \ 'test Xtest.c /^void test()$/;" f typeref:typename:void signature:()', | 508 \ 'test Xtest.c /^void test()$/;" f typeref:typename:void signature:()', |
532 \ ], 'Ytags') | 509 \ ], 'Ytags', 'D') |
533 cal writefile([ | 510 cal writefile([ |
534 \ 'int main()', | 511 \ 'int main()', |
535 \ 'void test()', | 512 \ 'void test()', |
536 \ ], 'Xtest.c') | 513 \ ], 'Xtest.c', 'D') |
537 cal writefile([ | 514 cal writefile([ |
538 \ 'void test();', | 515 \ 'void test();', |
539 \ ], 'Xtest.h') | 516 \ ], 'Xtest.h', 'D') |
540 set tags=Xtags,Ytags | 517 set tags=Xtags,Ytags |
541 | 518 |
542 new Xtest.c | 519 new Xtest.c |
543 let tl = taglist('test', 'Xtest.c') | 520 let tl = taglist('test', 'Xtest.c') |
544 call assert_equal(tl[0].filename, 'Xtest.c') | 521 call assert_equal(tl[0].filename, 'Xtest.c') |
550 call assert_equal(bufname('%'), 'Xtest.c') | 527 call assert_equal(bufname('%'), 'Xtest.c') |
551 2tag test | 528 2tag test |
552 call assert_equal(bufname('%'), 'Xtest.h') | 529 call assert_equal(bufname('%'), 'Xtest.h') |
553 | 530 |
554 set tags& | 531 set tags& |
555 call delete('Xtags') | |
556 call delete('Ytags') | |
557 bwipe Xtest.h | 532 bwipe Xtest.h |
558 bwipe Xtest.c | 533 bwipe Xtest.c |
559 call delete('Xtest.h') | |
560 call delete('Xtest.c') | |
561 endfunc | 534 endfunc |
562 | 535 |
563 func Test_tagnr_recall() | 536 func Test_tagnr_recall() |
564 call writefile([ | 537 call writefile([ |
565 \ 'test Xtest.h /^void test();$/;" p', | 538 \ 'test Xtest.h /^void test();$/;" p', |
566 \ 'main Xtest.c /^int main()$/;" f', | 539 \ 'main Xtest.c /^int main()$/;" f', |
567 \ 'test Xtest.c /^void test()$/;" f', | 540 \ 'test Xtest.c /^void test()$/;" f', |
568 \ ], 'Xtags') | 541 \ ], 'Xtags', 'D') |
569 cal writefile([ | 542 cal writefile([ |
570 \ 'int main()', | 543 \ 'int main()', |
571 \ 'void test()', | 544 \ 'void test()', |
572 \ ], 'Xtest.c') | 545 \ ], 'Xtest.c', 'D') |
573 cal writefile([ | 546 cal writefile([ |
574 \ 'void test();', | 547 \ 'void test();', |
575 \ ], 'Xtest.h') | 548 \ ], 'Xtest.h', 'D') |
576 set tags=Xtags | 549 set tags=Xtags |
577 | 550 |
578 new Xtest.c | 551 new Xtest.c |
579 let tl = taglist('test', 'Xtest.c') | 552 let tl = taglist('test', 'Xtest.c') |
580 call assert_equal(tl[0].filename, 'Xtest.c') | 553 call assert_equal(tl[0].filename, 'Xtest.c') |
586 call assert_equal(bufname('%'), 'Xtest.c') | 559 call assert_equal(bufname('%'), 'Xtest.c') |
587 tag | 560 tag |
588 call assert_equal(bufname('%'), 'Xtest.h') | 561 call assert_equal(bufname('%'), 'Xtest.h') |
589 | 562 |
590 set tags& | 563 set tags& |
591 call delete('Xtags') | |
592 bwipe Xtest.h | 564 bwipe Xtest.h |
593 bwipe Xtest.c | 565 bwipe Xtest.c |
594 call delete('Xtest.h') | |
595 call delete('Xtest.c') | |
596 endfunc | 566 endfunc |
597 | 567 |
598 func Test_tag_line_toolong() | 568 func Test_tag_line_toolong() |
599 call writefile([ | 569 call writefile([ |
600 \ '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML' | 570 \ '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML' |
601 \ ], 'Xtags') | 571 \ ], 'Xtags', 'D') |
602 set tags=Xtags | 572 set tags=Xtags |
603 let old_vbs = &verbose | 573 let old_vbs = &verbose |
604 set verbose=5 | 574 set verbose=5 |
605 " ":tjump" should give "tag not found" not "Format error in tags file" | 575 " ":tjump" should give "tag not found" not "Format error in tags file" |
606 call assert_fails('tj /foo', 'E426:') | 576 call assert_fails('tj /foo', 'E426:') |
633 call writefile([ | 603 call writefile([ |
634 \ 'one', | 604 \ 'one', |
635 \ 'two', | 605 \ 'two', |
636 \ 'trhee', | 606 \ 'trhee', |
637 \ 'four', | 607 \ 'four', |
638 \ ], 'Xsomewhere') | 608 \ ], 'Xsomewhere', 'D') |
639 tag foobar | 609 tag foobar |
640 call assert_equal('Xsomewhere', expand('%')) | 610 call assert_equal('Xsomewhere', expand('%')) |
641 call assert_equal(3, getcurpos()[1]) | 611 call assert_equal(3, getcurpos()[1]) |
642 | 612 |
643 " expansion on command line works with long lines when &wildoptions contains | 613 " expansion on command line works with long lines when &wildoptions contains |
648 \ ], 'Xtags') | 618 \ ], 'Xtags') |
649 call feedkeys(":tag \<Tab>", 'tx') | 619 call feedkeys(":tag \<Tab>", 'tx') |
650 " Should not crash | 620 " Should not crash |
651 call assert_true(v:true) | 621 call assert_true(v:true) |
652 | 622 |
653 call delete('Xtags') | |
654 call delete('Xsomewhere') | |
655 set tags& | 623 set tags& |
656 let &verbose = old_vbs | 624 let &verbose = old_vbs |
657 endfunc | 625 endfunc |
658 | 626 |
659 " Check that using :tselect does not run into the hit-enter prompt. | 627 " Check that using :tselect does not run into the hit-enter prompt. |
663 | 631 |
664 call writefile([ | 632 call writefile([ |
665 \ 'main Xtest.h /^void test();$/;" f', | 633 \ 'main Xtest.h /^void test();$/;" f', |
666 \ 'main Xtest.c /^int main()$/;" f', | 634 \ 'main Xtest.c /^int main()$/;" f', |
667 \ 'main Xtest.x /^void test()$/;" f', | 635 \ 'main Xtest.x /^void test()$/;" f', |
668 \ ], 'Xtags') | 636 \ ], 'Xtags', 'D') |
669 cal writefile([ | 637 cal writefile([ |
670 \ 'int main()', | 638 \ 'int main()', |
671 \ 'void test()', | 639 \ 'void test()', |
672 \ ], 'Xtest.c') | 640 \ ], 'Xtest.c', 'D') |
673 | 641 |
674 let lines =<< trim [SCRIPT] | 642 let lines =<< trim [SCRIPT] |
675 set tags=Xtags | 643 set tags=Xtags |
676 [SCRIPT] | 644 [SCRIPT] |
677 call writefile(lines, 'XTest_tselect') | 645 call writefile(lines, 'XTest_tselect', 'D') |
678 let buf = RunVimInTerminal('-S XTest_tselect', {'rows': 10, 'cols': 50}) | 646 let buf = RunVimInTerminal('-S XTest_tselect', {'rows': 10, 'cols': 50}) |
679 | 647 |
680 call TermWait(buf, 50) | 648 call TermWait(buf, 50) |
681 call term_sendkeys(buf, ":tselect main\<CR>2\<CR>") | 649 call term_sendkeys(buf, ":tselect main\<CR>2\<CR>") |
682 call VerifyScreenDump(buf, 'Test_tselect_1', {}) | 650 call VerifyScreenDump(buf, 'Test_tselect_1', {}) |
683 | 651 |
684 call StopVimInTerminal(buf) | 652 call StopVimInTerminal(buf) |
685 call delete('Xtags') | |
686 call delete('Xtest.c') | |
687 call delete('XTest_tselect') | |
688 endfunc | 653 endfunc |
689 | 654 |
690 func Test_tagline() | 655 func Test_tagline() |
691 call writefile([ | 656 call writefile([ |
692 \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo', | 657 \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo', |
693 \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:3 language:Python class:Bar', | 658 \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:3 language:Python class:Bar', |
694 \], 'Xtags') | 659 \], 'Xtags', 'D') |
695 call writefile([ | 660 call writefile([ |
696 \ ' def provision(self, **kwargs):', | 661 \ ' def provision(self, **kwargs):', |
697 \ ' pass', | 662 \ ' pass', |
698 \ ' def provision(self, **kwargs):', | 663 \ ' def provision(self, **kwargs):', |
699 \ ' pass', | 664 \ ' pass', |
700 \], 'Xtest.py') | 665 \], 'Xtest.py', 'D') |
701 | 666 |
702 set tags=Xtags | 667 set tags=Xtags |
703 | 668 |
704 1tag provision | 669 1tag provision |
705 call assert_equal(line('.'), 1) | 670 call assert_equal(line('.'), 1) |
706 2tag provision | 671 2tag provision |
707 call assert_equal(line('.'), 3) | 672 call assert_equal(line('.'), 3) |
708 | 673 |
709 call delete('Xtags') | |
710 call delete('Xtest.py') | |
711 set tags& | 674 set tags& |
712 endfunc | 675 endfunc |
713 | 676 |
714 " Test for expanding environment variable in a tag file name | 677 " Test for expanding environment variable in a tag file name |
715 func Test_tag_envvar() | 678 func Test_tag_envvar() |
716 call writefile(["Func1\t$FOO\t/^Func1/"], 'Xtags') | 679 call writefile(["Func1\t$FOO\t/^Func1/"], 'Xtags', 'D') |
717 set tags=Xtags | 680 set tags=Xtags |
718 | 681 |
719 let $FOO='TagTestEnv' | 682 let $FOO='TagTestEnv' |
720 | 683 |
721 let caught_exception = v:false | 684 let caught_exception = v:false |
726 let caught_exception = v:true | 689 let caught_exception = v:true |
727 endtry | 690 endtry |
728 call assert_true(caught_exception) | 691 call assert_true(caught_exception) |
729 | 692 |
730 set tags& | 693 set tags& |
731 call delete('Xtags') | |
732 unlet $FOO | 694 unlet $FOO |
733 endfunc | 695 endfunc |
734 | 696 |
735 " Test for :ptag | 697 " Test for :ptag |
736 func Test_tag_preview() | 698 func Test_tag_preview() |
737 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 699 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
738 \ "second\tXtpfile1\t2", | 700 \ "second\tXtpfile1\t2", |
739 \ "third\tXtpfile1\t3",], | 701 \ "third\tXtpfile1\t3",], |
740 \ 'Xtags') | 702 \ 'Xtags', 'D') |
741 set tags=Xtags | 703 set tags=Xtags |
742 call writefile(['first', 'second', 'third'], 'Xtpfile1') | 704 call writefile(['first', 'second', 'third'], 'Xtpfile1', 'D') |
743 | 705 |
744 enew | only | 706 enew | only |
745 ptag third | 707 ptag third |
746 call assert_equal(2, winnr()) | 708 call assert_equal(2, winnr()) |
747 call assert_equal(2, winnr('$')) | 709 call assert_equal(2, winnr('$')) |
764 | 726 |
765 " close the preview window | 727 " close the preview window |
766 pclose | 728 pclose |
767 call assert_equal(1, winnr('$')) | 729 call assert_equal(1, winnr('$')) |
768 | 730 |
769 call delete('Xtpfile1') | |
770 call delete('Xtags') | |
771 set tags& | 731 set tags& |
772 endfunc | 732 endfunc |
773 | 733 |
774 " Tests for guessing the tag location | 734 " Tests for guessing the tag location |
775 func Test_tag_guess() | 735 func Test_tag_guess() |
776 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 736 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
777 \ "func1\tXfoo\t/^int func1(int x)/", | 737 \ "func1\tXfoo\t/^int func1(int x)/", |
778 \ "func2\tXfoo\t/^int func2(int y)/", | 738 \ "func2\tXfoo\t/^int func2(int y)/", |
779 \ "func3\tXfoo\t/^func3/", | 739 \ "func3\tXfoo\t/^func3/", |
780 \ "func4\tXfoo\t/^func4/"], | 740 \ "func4\tXfoo\t/^func4/"], |
781 \ 'Xtags') | 741 \ 'Xtags', 'D') |
782 set tags=Xtags | 742 set tags=Xtags |
783 let code =<< trim [CODE] | 743 let code =<< trim [CODE] |
784 | 744 |
785 int FUNC1 (int x) { } | 745 int FUNC1 (int x) { } |
786 int | 746 int |
787 func2 (int y) { } | 747 func2 (int y) { } |
788 int * func3 () { } | 748 int * func3 () { } |
789 | 749 |
790 [CODE] | 750 [CODE] |
791 call writefile(code, 'Xfoo') | 751 call writefile(code, 'Xfoo', 'D') |
792 | 752 |
793 let v:statusmsg = '' | 753 let v:statusmsg = '' |
794 ta func1 | 754 ta func1 |
795 call assert_match('E435:', v:statusmsg) | 755 call assert_match('E435:', v:statusmsg) |
796 call assert_equal(2, line('.')) | 756 call assert_equal(2, line('.')) |
802 ta func3 | 762 ta func3 |
803 call assert_match('E435:', v:statusmsg) | 763 call assert_match('E435:', v:statusmsg) |
804 call assert_equal(5, line('.')) | 764 call assert_equal(5, line('.')) |
805 call assert_fails('ta func4', 'E434:') | 765 call assert_fails('ta func4', 'E434:') |
806 | 766 |
807 call delete('Xtags') | |
808 call delete('Xfoo') | |
809 set tags& | 767 set tags& |
810 endfunc | 768 endfunc |
811 | 769 |
812 " Test for an unsorted tags file | 770 " Test for an unsorted tags file |
813 func Test_tag_sort() | 771 func Test_tag_sort() |
814 let l = [ | 772 let l = [ |
815 \ "first\tXfoo\t1", | 773 \ "first\tXfoo\t1", |
816 \ "ten\tXfoo\t3", | 774 \ "ten\tXfoo\t3", |
817 \ "six\tXfoo\t2"] | 775 \ "six\tXfoo\t2"] |
818 call writefile(l, 'Xtags') | 776 call writefile(l, 'Xtags', 'D') |
819 set tags=Xtags | 777 set tags=Xtags |
820 let code =<< trim [CODE] | 778 let code =<< trim [CODE] |
821 int first() {} | 779 int first() {} |
822 int six() {} | 780 int six() {} |
823 int ten() {} | 781 int ten() {} |
824 [CODE] | 782 [CODE] |
825 call writefile(code, 'Xfoo') | 783 call writefile(code, 'Xfoo', 'D') |
826 | 784 |
827 call assert_fails('tag first', 'E432:') | 785 call assert_fails('tag first', 'E432:') |
828 | 786 |
829 " When multiple tag files are not sorted, then message should be displayed | 787 " When multiple tag files are not sorted, then message should be displayed |
830 " multiple times | 788 " multiple times |
831 call writefile(l, 'Xtags2') | 789 call writefile(l, 'Xtags2', 'D') |
832 set tags=Xtags,Xtags2 | 790 set tags=Xtags,Xtags2 |
833 call assert_fails('tag first', ['E432:', 'E432:']) | 791 call assert_fails('tag first', ['E432:', 'E432:']) |
834 | 792 |
835 call delete('Xtags') | |
836 call delete('Xtags2') | |
837 call delete('Xfoo') | |
838 set tags& | 793 set tags& |
839 %bwipe | 794 %bwipe |
840 endfunc | 795 endfunc |
841 | 796 |
842 " Test for an unsorted tags file | 797 " Test for an unsorted tags file |
845 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 800 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
846 \ "!_TAG_FILE_SORTED\t2\t/0=unsorted, 1=sorted, 2=foldcase/", | 801 \ "!_TAG_FILE_SORTED\t2\t/0=unsorted, 1=sorted, 2=foldcase/", |
847 \ "first\tXfoo\t1", | 802 \ "first\tXfoo\t1", |
848 \ "second\tXfoo\t2", | 803 \ "second\tXfoo\t2", |
849 \ "third\tXfoo\t3"], | 804 \ "third\tXfoo\t3"], |
850 \ 'Xtags') | 805 \ 'Xtags', 'D') |
851 set tags=Xtags | 806 set tags=Xtags |
852 let code =<< trim [CODE] | 807 let code =<< trim [CODE] |
853 int first() {} | 808 int first() {} |
854 int second() {} | 809 int second() {} |
855 int third() {} | 810 int third() {} |
856 [CODE] | 811 [CODE] |
857 call writefile(code, 'Xfoo') | 812 call writefile(code, 'Xfoo', 'D') |
858 | 813 |
859 enew | 814 enew |
860 tag second | 815 tag second |
861 call assert_equal('Xfoo', bufname('')) | 816 call assert_equal('Xfoo', bufname('')) |
862 call assert_equal(2, line('.')) | 817 call assert_equal(2, line('.')) |
863 | 818 |
864 call delete('Xtags') | |
865 call delete('Xfoo') | |
866 set tags& | 819 set tags& |
867 %bwipe | 820 %bwipe |
868 endfunc | 821 endfunc |
869 | 822 |
870 " Test for the :ltag command | 823 " Test for the :ltag command |
872 call writefile([ | 825 call writefile([ |
873 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 826 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
874 \ "first\tXfoo\t1", | 827 \ "first\tXfoo\t1", |
875 \ "second\tXfoo\t/^int second() {}$/", | 828 \ "second\tXfoo\t/^int second() {}$/", |
876 \ "third\tXfoo\t3"], | 829 \ "third\tXfoo\t3"], |
877 \ 'Xtags') | 830 \ 'Xtags', 'D') |
878 set tags=Xtags | 831 set tags=Xtags |
879 let code =<< trim [CODE] | 832 let code =<< trim [CODE] |
880 int first() {} | 833 int first() {} |
881 int second() {} | 834 int second() {} |
882 int third() {} | 835 int third() {} |
883 [CODE] | 836 [CODE] |
884 call writefile(code, 'Xfoo') | 837 call writefile(code, 'Xfoo', 'D') |
885 | 838 |
886 enew | 839 enew |
887 call setloclist(0, [], 'f') | 840 call setloclist(0, [], 'f') |
888 ltag third | 841 ltag third |
889 call assert_equal('Xfoo', bufname('')) | 842 call assert_equal('Xfoo', bufname('')) |
897 call assert_equal([{'lnum': 0, 'end_lnum': 0, 'bufnr': bufnr('Xfoo'), | 850 call assert_equal([{'lnum': 0, 'end_lnum': 0, 'bufnr': bufnr('Xfoo'), |
898 \ 'col': 0, 'end_col': 0, 'pattern': '^\Vint second() {}\$', | 851 \ 'col': 0, 'end_col': 0, 'pattern': '^\Vint second() {}\$', |
899 \ 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'module': '', | 852 \ 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'module': '', |
900 \ 'text': 'second'}], getloclist(0)) | 853 \ 'text': 'second'}], getloclist(0)) |
901 | 854 |
902 call delete('Xtags') | |
903 call delete('Xfoo') | |
904 set tags& | 855 set tags& |
905 %bwipe | 856 %bwipe |
906 endfunc | 857 endfunc |
907 | 858 |
908 " Test for setting the last search pattern to the tag search pattern | 859 " Test for setting the last search pattern to the tag search pattern |
911 call writefile([ | 862 call writefile([ |
912 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 863 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
913 \ "first\tXfoo\t/^int first() {}/", | 864 \ "first\tXfoo\t/^int first() {}/", |
914 \ "second\tXfoo\t/^int second() {}/", | 865 \ "second\tXfoo\t/^int second() {}/", |
915 \ "third\tXfoo\t/^int third() {}/"], | 866 \ "third\tXfoo\t/^int third() {}/"], |
916 \ 'Xtags') | 867 \ 'Xtags', 'D') |
917 set tags=Xtags | 868 set tags=Xtags |
918 let code =<< trim [CODE] | 869 let code =<< trim [CODE] |
919 int first() {} | 870 int first() {} |
920 int second() {} | 871 int second() {} |
921 int third() {} | 872 int third() {} |
922 [CODE] | 873 [CODE] |
923 call writefile(code, 'Xfoo') | 874 call writefile(code, 'Xfoo', 'D') |
924 | 875 |
925 enew | 876 enew |
926 let save_cpo = &cpo | 877 let save_cpo = &cpo |
927 set cpo+=t | 878 set cpo+=t |
928 let @/ = '' | 879 let @/ = '' |
929 tag second | 880 tag second |
930 call assert_equal('^int second() {}', @/) | 881 call assert_equal('^int second() {}', @/) |
931 let &cpo = save_cpo | 882 let &cpo = save_cpo |
932 | 883 |
933 call delete('Xtags') | |
934 call delete('Xfoo') | |
935 set tags& | 884 set tags& |
936 %bwipe | 885 %bwipe |
937 endfunc | 886 endfunc |
938 | 887 |
939 " Tag stack tests | 888 " Tag stack tests |
940 func Test_tag_stack() | 889 func Test_tag_stack() |
941 let l = [] | 890 let l = [] |
942 for i in range(10, 31) | 891 for i in range(10, 31) |
943 let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"] | 892 let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"] |
944 endfor | 893 endfor |
945 call writefile(l, 'Xtags') | 894 call writefile(l, 'Xtags', 'D') |
946 set tags=Xtags | 895 set tags=Xtags |
947 | 896 |
948 let l = [] | 897 let l = [] |
949 for i in range(10, 31) | 898 for i in range(10, 31) |
950 let l += ["int var" .. i .. ";"] | 899 let l += ["int var" .. i .. ";"] |
951 endfor | 900 endfor |
952 call writefile(l, 'Xfoo') | 901 call writefile(l, 'Xfoo', 'D') |
953 | 902 |
954 " Jump to a tag when the tag stack is full. Oldest entry should be removed. | 903 " Jump to a tag when the tag stack is full. Oldest entry should be removed. |
955 enew | 904 enew |
956 for i in range(10, 30) | 905 for i in range(10, 30) |
957 exe "tag var" .. i | 906 exe "tag var" .. i |
992 | 941 |
993 " Pop the tag stack when it is empty | 942 " Pop the tag stack when it is empty |
994 call settagstack(1, {'items' : []}) | 943 call settagstack(1, {'items' : []}) |
995 call assert_fails('pop', 'E73:') | 944 call assert_fails('pop', 'E73:') |
996 | 945 |
997 call delete('Xtags') | |
998 call delete('Xfoo') | |
999 set tags& | 946 set tags& |
1000 %bwipe | 947 %bwipe |
1001 endfunc | 948 endfunc |
1002 | 949 |
1003 " Test for browsing multiple matching tags | 950 " Test for browsing multiple matching tags |
1005 call writefile([ | 952 call writefile([ |
1006 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 953 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
1007 \ "first\tXfoo\t1", | 954 \ "first\tXfoo\t1", |
1008 \ "first\tXfoo\t2", | 955 \ "first\tXfoo\t2", |
1009 \ "first\tXfoo\t3"], | 956 \ "first\tXfoo\t3"], |
1010 \ 'Xtags') | 957 \ 'Xtags', 'D') |
1011 set tags=Xtags | 958 set tags=Xtags |
1012 let code =<< trim [CODE] | 959 let code =<< trim [CODE] |
1013 int first() {} | 960 int first() {} |
1014 int first() {} | 961 int first() {} |
1015 int first() {} | 962 int first() {} |
1016 [CODE] | 963 [CODE] |
1017 call writefile(code, 'Xfoo') | 964 call writefile(code, 'Xfoo', 'D') |
1018 | 965 |
1019 call settagstack(1, {'items' : []}) | 966 call settagstack(1, {'items' : []}) |
1020 tag first | 967 tag first |
1021 tlast | 968 tlast |
1022 call assert_equal(3, line('.')) | 969 call assert_equal(3, line('.')) |
1039 call assert_equal(2, line('.')) | 986 call assert_equal(2, line('.')) |
1040 tNext | 987 tNext |
1041 call assert_equal(1, line('.')) | 988 call assert_equal(1, line('.')) |
1042 set ignorecase& | 989 set ignorecase& |
1043 | 990 |
1044 call delete('Xtags') | |
1045 call delete('Xfoo') | |
1046 set tags& | 991 set tags& |
1047 %bwipe | 992 %bwipe |
1048 endfunc | 993 endfunc |
1049 | 994 |
1050 " Test for previewing multiple matching tags | 995 " Test for previewing multiple matching tags |
1052 call writefile([ | 997 call writefile([ |
1053 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 998 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
1054 \ "first\tXfoo\t1", | 999 \ "first\tXfoo\t1", |
1055 \ "first\tXfoo\t2", | 1000 \ "first\tXfoo\t2", |
1056 \ "first\tXfoo\t3"], | 1001 \ "first\tXfoo\t3"], |
1057 \ 'Xtags') | 1002 \ 'Xtags', 'D') |
1058 set tags=Xtags | 1003 set tags=Xtags |
1059 let code =<< trim [CODE] | 1004 let code =<< trim [CODE] |
1060 int first() {} | 1005 int first() {} |
1061 int first() {} | 1006 int first() {} |
1062 int first() {} | 1007 int first() {} |
1063 [CODE] | 1008 [CODE] |
1064 call writefile(code, 'Xfoo') | 1009 call writefile(code, 'Xfoo', 'D') |
1065 | 1010 |
1066 enew | only | 1011 enew | only |
1067 ptag first | 1012 ptag first |
1068 ptlast | 1013 ptlast |
1069 wincmd P | 1014 wincmd P |
1089 wincmd P | 1034 wincmd P |
1090 call assert_equal(3, line('.')) | 1035 call assert_equal(3, line('.')) |
1091 | 1036 |
1092 pclose | 1037 pclose |
1093 | 1038 |
1094 call delete('Xtags') | |
1095 call delete('Xfoo') | |
1096 set tags& | 1039 set tags& |
1097 %bwipe | 1040 %bwipe |
1098 endfunc | 1041 endfunc |
1099 | 1042 |
1100 " Test for jumping to multiple matching tags across multiple :tags commands | 1043 " Test for jumping to multiple matching tags across multiple :tags commands |
1102 call writefile([ | 1045 call writefile([ |
1103 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 1046 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
1104 \ "first\tXfoo1\t1", | 1047 \ "first\tXfoo1\t1", |
1105 \ "first\tXfoo2\t1", | 1048 \ "first\tXfoo2\t1", |
1106 \ "first\tXfoo3\t1"], | 1049 \ "first\tXfoo3\t1"], |
1107 \ 'Xtags') | 1050 \ 'Xtags', 'D') |
1108 set tags=Xtags | 1051 set tags=Xtags |
1109 let code =<< trim [CODE] | 1052 let code =<< trim [CODE] |
1110 int first() {} | 1053 int first() {} |
1111 [CODE] | 1054 [CODE] |
1112 call writefile(code, 'Xfoo1') | 1055 call writefile(code, 'Xfoo1', 'D') |
1113 call writefile(code, 'Xfoo2') | 1056 call writefile(code, 'Xfoo2', 'D') |
1114 call writefile(code, 'Xfoo3') | 1057 call writefile(code, 'Xfoo3', 'D') |
1115 | 1058 |
1116 tag first | 1059 tag first |
1117 tag first | 1060 tag first |
1118 pop | 1061 pop |
1119 tnext | 1062 tnext |
1120 tnext | 1063 tnext |
1121 call assert_fails('tnext', 'E428:') | 1064 call assert_fails('tnext', 'E428:') |
1122 | 1065 |
1123 call delete('Xtags') | |
1124 call delete('Xfoo1') | |
1125 call delete('Xfoo2') | |
1126 call delete('Xfoo3') | |
1127 set tags& | 1066 set tags& |
1128 %bwipe | 1067 %bwipe |
1129 endfunc | 1068 endfunc |
1130 | 1069 |
1131 " Test for jumping to multiple matching tags in non-existing files | 1070 " Test for jumping to multiple matching tags in non-existing files |
1133 call writefile([ | 1072 call writefile([ |
1134 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 1073 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
1135 \ "first\tXfoo1\t1", | 1074 \ "first\tXfoo1\t1", |
1136 \ "first\tXfoo2\t1", | 1075 \ "first\tXfoo2\t1", |
1137 \ "first\tXfoo3\t1"], | 1076 \ "first\tXfoo3\t1"], |
1138 \ 'Xtags') | 1077 \ 'Xtags', 'D') |
1139 set tags=Xtags | 1078 set tags=Xtags |
1140 | 1079 |
1141 call settagstack(1, {'items' : []}) | 1080 call settagstack(1, {'items' : []}) |
1142 call assert_fails('tag first', 'E429:') | 1081 call assert_fails('tag first', 'E429:') |
1143 call assert_equal(3, gettagstack().items[0].matchnr) | 1082 call assert_equal(3, gettagstack().items[0].matchnr) |
1144 | 1083 |
1145 call delete('Xtags') | |
1146 set tags& | 1084 set tags& |
1147 %bwipe | 1085 %bwipe |
1148 endfunc | 1086 endfunc |
1149 | 1087 |
1150 func Test_tselect_listing() | 1088 func Test_tselect_listing() |
1151 call writefile([ | 1089 call writefile([ |
1152 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 1090 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
1153 \ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:", | 1091 \ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:", |
1154 \ "first\tXfoo\t2" .. ';"' .. "\tkind:v\ttyperef:typename:char\tfile:"], | 1092 \ "first\tXfoo\t2" .. ';"' .. "\tkind:v\ttyperef:typename:char\tfile:"], |
1155 \ 'Xtags') | 1093 \ 'Xtags', 'D') |
1156 set tags=Xtags | 1094 set tags=Xtags |
1157 | 1095 |
1158 let code =<< trim [CODE] | 1096 let code =<< trim [CODE] |
1159 static int first; | 1097 static int first; |
1160 static char first; | 1098 static char first; |
1161 [CODE] | 1099 [CODE] |
1162 call writefile(code, 'Xfoo') | 1100 call writefile(code, 'Xfoo', 'D') |
1163 | 1101 |
1164 call feedkeys("\<CR>", "t") | 1102 call feedkeys("\<CR>", "t") |
1165 let l = split(execute("tselect first"), "\n") | 1103 let l = split(execute("tselect first"), "\n") |
1166 let expected =<< [DATA] | 1104 let expected =<< [DATA] |
1167 # pri kind tag file | 1105 # pri kind tag file |
1173 2 | 1111 2 |
1174 Type number and <Enter> (q or empty cancels): | 1112 Type number and <Enter> (q or empty cancels): |
1175 [DATA] | 1113 [DATA] |
1176 call assert_equal(expected, l) | 1114 call assert_equal(expected, l) |
1177 | 1115 |
1178 call delete('Xtags') | |
1179 call delete('Xfoo') | |
1180 set tags& | 1116 set tags& |
1181 %bwipe | 1117 %bwipe |
1182 endfunc | 1118 endfunc |
1183 | 1119 |
1184 " Test for :isearch, :ilist, :ijump and :isplit commands | 1120 " Test for :isearch, :ilist, :ijump and :isplit commands |
1452 " Test for the 'taglength' option | 1388 " Test for the 'taglength' option |
1453 func Test_tag_length() | 1389 func Test_tag_length() |
1454 set tags=Xtags | 1390 set tags=Xtags |
1455 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 1391 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
1456 \ "tame\tXtlfile1\t1;", | 1392 \ "tame\tXtlfile1\t1;", |
1457 \ "tape\tXtlfile2\t1;"], 'Xtags') | 1393 \ "tape\tXtlfile2\t1;"], 'Xtags', 'D') |
1458 call writefile(['tame'], 'Xtlfile1') | 1394 call writefile(['tame'], 'Xtlfile1', 'D') |
1459 call writefile(['tape'], 'Xtlfile2') | 1395 call writefile(['tape'], 'Xtlfile2', 'D') |
1460 | 1396 |
1461 " Jumping to the tag 'tape', should instead jump to 'tame' | 1397 " Jumping to the tag 'tape', should instead jump to 'tame' |
1462 new | 1398 new |
1463 set taglength=2 | 1399 set taglength=2 |
1464 tag tape | 1400 tag tape |
1466 " Tag search should jump to the right tag | 1402 " Tag search should jump to the right tag |
1467 enew | 1403 enew |
1468 tag /^tape$ | 1404 tag /^tape$ |
1469 call assert_equal('Xtlfile2', @%) | 1405 call assert_equal('Xtlfile2', @%) |
1470 | 1406 |
1471 call delete('Xtags') | |
1472 call delete('Xtlfile1') | |
1473 call delete('Xtlfile2') | |
1474 set tags& taglength& | 1407 set tags& taglength& |
1475 endfunc | 1408 endfunc |
1476 | 1409 |
1477 " Tests for errors in a tags file | 1410 " Tests for errors in a tags file |
1478 func Test_tagfile_errors() | 1411 func Test_tagfile_errors() |
1479 set tags=Xtags | 1412 set tags=Xtags |
1480 | 1413 |
1481 " missing search pattern or line number for a tag | 1414 " missing search pattern or line number for a tag |
1482 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 1415 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
1483 \ "foo\tXfile\t"], 'Xtags', 'b') | 1416 \ "foo\tXfile\t"], 'Xtags', 'bD') |
1484 call writefile(['foo'], 'Xfile') | 1417 call writefile(['foo'], 'Xfile', 'D') |
1485 | 1418 |
1486 enew | 1419 enew |
1487 tag foo | 1420 tag foo |
1488 call assert_equal('', @%) | 1421 call assert_equal('', @%) |
1489 let caught_431 = v:false | 1422 let caught_431 = v:false |
1502 " file name and search pattern are not separated by a tab | 1435 " file name and search pattern are not separated by a tab |
1503 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 1436 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
1504 \ "foo\tXfile 1;"], 'Xtags') | 1437 \ "foo\tXfile 1;"], 'Xtags') |
1505 call assert_fails('tag foo', 'E431:') | 1438 call assert_fails('tag foo', 'E431:') |
1506 | 1439 |
1507 call delete('Xtags') | |
1508 call delete('Xfile') | |
1509 set tags& | 1440 set tags& |
1510 endfunc | 1441 endfunc |
1511 | 1442 |
1512 " When :stag fails to open the file, should close the new window | 1443 " When :stag fails to open the file, should close the new window |
1513 func Test_stag_close_window_on_error() | 1444 func Test_stag_close_window_on_error() |
1514 new | only | 1445 new | only |
1515 set tags=Xtags | 1446 set tags=Xtags |
1516 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", | 1447 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", |
1517 \ "foo\tXfile\t1"], 'Xtags') | 1448 \ "foo\tXfile\t1"], 'Xtags', 'D') |
1518 call writefile(['foo'], 'Xfile') | 1449 call writefile(['foo'], 'Xfile', 'D') |
1519 call writefile([], '.Xfile.swp') | 1450 call writefile([], '.Xfile.swp', 'D') |
1520 " Remove the catch-all that runtest.vim adds | 1451 " Remove the catch-all that runtest.vim adds |
1521 au! SwapExists | 1452 au! SwapExists |
1522 augroup StagTest | 1453 augroup StagTest |
1523 au! | 1454 au! |
1524 autocmd SwapExists Xfile let v:swapchoice='q' | 1455 autocmd SwapExists Xfile let v:swapchoice='q' |
1529 call assert_equal('', @%) | 1460 call assert_equal('', @%) |
1530 | 1461 |
1531 augroup StagTest | 1462 augroup StagTest |
1532 au! | 1463 au! |
1533 augroup END | 1464 augroup END |
1534 call delete('Xfile') | |
1535 call delete('.Xfile.swp') | |
1536 set tags& | 1465 set tags& |
1537 endfunc | 1466 endfunc |
1538 | 1467 |
1539 " Test for 'tagbsearch' (binary search) | 1468 " Test for 'tagbsearch' (binary search) |
1540 func Test_tagbsearch() | 1469 func Test_tagbsearch() |
1544 \ "!_TAG_FILE_ENCODING\tutf-8\t//", | 1473 \ "!_TAG_FILE_ENCODING\tutf-8\t//", |
1545 \ "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted, 2=foldcase/", | 1474 \ "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted, 2=foldcase/", |
1546 \ "third\tXfoo\t3", | 1475 \ "third\tXfoo\t3", |
1547 \ "second\tXfoo\t2", | 1476 \ "second\tXfoo\t2", |
1548 \ "first\tXfoo\t1"], | 1477 \ "first\tXfoo\t1"], |
1549 \ 'Xtags') | 1478 \ 'Xtags', 'D') |
1550 set tags=Xtags | 1479 set tags=Xtags |
1551 let code =<< trim [CODE] | 1480 let code =<< trim [CODE] |
1552 int first() {} | 1481 int first() {} |
1553 int second() {} | 1482 int second() {} |
1554 int third() {} | 1483 int third() {} |
1555 [CODE] | 1484 [CODE] |
1556 call writefile(code, 'Xfoo') | 1485 call writefile(code, 'Xfoo', 'D') |
1557 | 1486 |
1558 enew | 1487 enew |
1559 set tagbsearch | 1488 set tagbsearch |
1560 call assert_fails('tag first', 'E426:') | 1489 call assert_fails('tag first', 'E426:') |
1561 call assert_equal('', bufname()) | 1490 call assert_equal('', bufname()) |
1611 \ "bar\tXfoo\t1", | 1540 \ "bar\tXfoo\t1", |
1612 \ "foo\tXfoo\t2"], | 1541 \ "foo\tXfoo\t2"], |
1613 \ 'Xtags') | 1542 \ 'Xtags') |
1614 call assert_fails('tag bbb', 'E426:') | 1543 call assert_fails('tag bbb', 'E426:') |
1615 | 1544 |
1616 call delete('Xtags') | |
1617 call delete('Xfoo') | |
1618 set tags& tagbsearch& | 1545 set tags& tagbsearch& |
1619 endfunc | 1546 endfunc |
1620 | 1547 |
1621 " vim: shiftwidth=2 sts=2 expandtab | 1548 " vim: shiftwidth=2 sts=2 expandtab |