Mercurial > vim
comparison src/testdir/test_quickfix.vim @ 11195:13c660bd07b2 v8.0.0484
patch 8.0.0484: :lhelpgrep does not fail after a successful one
commit https://github.com/vim/vim/commit/ee85df37634dfb0c40ae5de0b4f246aef460b392
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 19 14:19:50 2017 +0100
patch 8.0.0484: :lhelpgrep does not fail after a successful one
Problem: Using :lhelpgrep with an argument that should fail does not
produce an error if the previous :helpgrep worked.
Solution: Use another way to detect that autocommands made the quickfix info
invalid. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 19 Mar 2017 14:30:04 +0100 |
parents | 9d40a98f0834 |
children | ae5f9f26f81c |
comparison
equal
deleted
inserted
replaced
11194:a6434de9107c | 11195:13c660bd07b2 |
---|---|
29 command! -nargs=* -bang Xfirst <mods>cfirst<bang> <args> | 29 command! -nargs=* -bang Xfirst <mods>cfirst<bang> <args> |
30 command! -nargs=* -bang Xlast <mods>clast<bang> <args> | 30 command! -nargs=* -bang Xlast <mods>clast<bang> <args> |
31 command! -nargs=* -bang Xnfile <mods>cnfile<bang> <args> | 31 command! -nargs=* -bang Xnfile <mods>cnfile<bang> <args> |
32 command! -nargs=* -bang Xpfile <mods>cpfile<bang> <args> | 32 command! -nargs=* -bang Xpfile <mods>cpfile<bang> <args> |
33 command! -nargs=* Xexpr <mods>cexpr <args> | 33 command! -nargs=* Xexpr <mods>cexpr <args> |
34 command! -nargs=* Xvimgrep <mods>vimgrep <args> | 34 command! -range -nargs=* Xvimgrep <mods><count>vimgrep <args> |
35 command! -nargs=* Xvimgrepadd <mods>vimgrepadd <args> | |
35 command! -nargs=* Xgrep <mods> grep <args> | 36 command! -nargs=* Xgrep <mods> grep <args> |
36 command! -nargs=* Xgrepadd <mods> grepadd <args> | 37 command! -nargs=* Xgrepadd <mods> grepadd <args> |
37 command! -nargs=* Xhelpgrep helpgrep <args> | 38 command! -nargs=* Xhelpgrep helpgrep <args> |
38 let g:Xgetlist = function('getqflist') | 39 let g:Xgetlist = function('getqflist') |
39 let g:Xsetlist = function('setqflist') | 40 let g:Xsetlist = function('setqflist') |
59 command! -nargs=* -bang Xfirst <mods>lfirst<bang> <args> | 60 command! -nargs=* -bang Xfirst <mods>lfirst<bang> <args> |
60 command! -nargs=* -bang Xlast <mods>llast<bang> <args> | 61 command! -nargs=* -bang Xlast <mods>llast<bang> <args> |
61 command! -nargs=* -bang Xnfile <mods>lnfile<bang> <args> | 62 command! -nargs=* -bang Xnfile <mods>lnfile<bang> <args> |
62 command! -nargs=* -bang Xpfile <mods>lpfile<bang> <args> | 63 command! -nargs=* -bang Xpfile <mods>lpfile<bang> <args> |
63 command! -nargs=* Xexpr <mods>lexpr <args> | 64 command! -nargs=* Xexpr <mods>lexpr <args> |
64 command! -nargs=* Xvimgrep <mods>lvimgrep <args> | 65 command! -range -nargs=* Xvimgrep <mods><count>lvimgrep <args> |
66 command! -nargs=* Xvimgrepadd <mods>lvimgrepadd <args> | |
65 command! -nargs=* Xgrep <mods> lgrep <args> | 67 command! -nargs=* Xgrep <mods> lgrep <args> |
66 command! -nargs=* Xgrepadd <mods> lgrepadd <args> | 68 command! -nargs=* Xgrepadd <mods> lgrepadd <args> |
67 command! -nargs=* Xhelpgrep lhelpgrep <args> | 69 command! -nargs=* Xhelpgrep lhelpgrep <args> |
68 let g:Xgetlist = function('getloclist', [0]) | 70 let g:Xgetlist = function('getloclist', [0]) |
69 let g:Xsetlist = function('setloclist', [0]) | 71 let g:Xsetlist = function('setloclist', [0]) |
83 Xgetexpr ['non-error 1', 'Xtestfile1:1:3:Line1', | 85 Xgetexpr ['non-error 1', 'Xtestfile1:1:3:Line1', |
84 \ 'non-error 2', 'Xtestfile2:2:2:Line2', | 86 \ 'non-error 2', 'Xtestfile2:2:2:Line2', |
85 \ 'non-error 3', 'Xtestfile3:3:1:Line3'] | 87 \ 'non-error 3', 'Xtestfile3:3:1:Line3'] |
86 | 88 |
87 " List only valid entries | 89 " List only valid entries |
88 redir => result | 90 let l = split(execute('Xlist', ''), "\n") |
89 Xlist | |
90 redir END | |
91 let l = split(result, "\n") | |
92 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', | 91 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', |
93 \ ' 4 Xtestfile2:2 col 2: Line2', | 92 \ ' 4 Xtestfile2:2 col 2: Line2', |
94 \ ' 6 Xtestfile3:3 col 1: Line3'], l) | 93 \ ' 6 Xtestfile3:3 col 1: Line3'], l) |
95 | 94 |
96 " List all the entries | 95 " List all the entries |
97 redir => result | 96 let l = split(execute('Xlist!', ''), "\n") |
98 Xlist! | |
99 redir END | |
100 let l = split(result, "\n") | |
101 call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1', | 97 call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1', |
102 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2', | 98 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2', |
103 \ ' 5: non-error 3', ' 6 Xtestfile3:3 col 1: Line3'], l) | 99 \ ' 5: non-error 3', ' 6 Xtestfile3:3 col 1: Line3'], l) |
104 | 100 |
105 " List a range of errors | 101 " List a range of errors |
106 redir => result | 102 let l = split(execute('Xlist 3,6', ''), "\n") |
107 Xlist 3,6 | |
108 redir END | |
109 let l = split(result, "\n") | |
110 call assert_equal([' 4 Xtestfile2:2 col 2: Line2', | 103 call assert_equal([' 4 Xtestfile2:2 col 2: Line2', |
111 \ ' 6 Xtestfile3:3 col 1: Line3'], l) | 104 \ ' 6 Xtestfile3:3 col 1: Line3'], l) |
112 | 105 |
113 redir => result | 106 let l = split(execute('Xlist! 3,4', ''), "\n") |
114 Xlist! 3,4 | |
115 redir END | |
116 let l = split(result, "\n") | |
117 call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) | 107 call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) |
118 | 108 |
119 redir => result | 109 let l = split(execute('Xlist -6,-4', ''), "\n") |
120 Xlist -6,-4 | |
121 redir END | |
122 let l = split(result, "\n") | |
123 call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l) | 110 call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l) |
124 | 111 |
125 redir => result | 112 let l = split(execute('Xlist! -5,-3', ''), "\n") |
126 Xlist! -5,-3 | |
127 redir END | |
128 let l = split(result, "\n") | |
129 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', | 113 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', |
130 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) | 114 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) |
131 | 115 |
132 " Test for '+' | 116 " Test for '+' |
133 redir => result | 117 let l = split(execute('Xlist! +2', ''), "\n") |
134 Xlist! +2 | |
135 redir END | |
136 let l = split(result, "\n") | |
137 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', | 118 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', |
138 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) | 119 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) |
120 | |
121 " Different types of errors | |
122 call g:Xsetlist([{'lnum':10,'col':5,'type':'W', 'text':'Warning','nr':11}, | |
123 \ {'lnum':20,'col':10,'type':'e','text':'Error','nr':22}, | |
124 \ {'lnum':30,'col':15,'type':'i','text':'Info','nr':33}, | |
125 \ {'lnum':40,'col':20,'type':'x', 'text':'Other','nr':44}, | |
126 \ {'lnum':50,'col':25,'type':"\<C-A>",'text':'one','nr':55}]) | |
127 let l = split(execute('Xlist', ""), "\n") | |
128 call assert_equal([' 1:10 col 5 warning 11: Warning', | |
129 \ ' 2:20 col 10 error 22: Error', | |
130 \ ' 3:30 col 15 info 33: Info', | |
131 \ ' 4:40 col 20 x 44: Other', | |
132 \ ' 5:50 col 25 55: one'], l) | |
133 | |
134 " Error cases | |
135 call assert_fails('Xlist abc', 'E488:') | |
139 endfunc | 136 endfunc |
140 | 137 |
141 func Test_clist() | 138 func Test_clist() |
142 call XlistTests('c') | 139 call XlistTests('c') |
143 call XlistTests('l') | 140 call XlistTests('l') |
322 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && | 319 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && |
323 \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && | 320 \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && |
324 \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') | 321 \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') |
325 enew! | 322 enew! |
326 | 323 |
324 " Check for invalid buffer | |
325 call assert_fails('Xbuffer 199', 'E474:') | |
326 | |
327 " Check for unloaded buffer | |
328 edit Xtestfile1 | |
329 let bnr = bufnr('%') | |
330 enew! | |
331 call assert_fails('Xbuffer ' . bnr, 'E681:') | |
332 | |
333 " Check for invalid range | |
334 " Using Xbuffer will not run the range check in the cbuffer/lbuffer | |
335 " commands. So directly call the commands. | |
336 if (a:cchar == 'c') | |
337 call assert_fails('900,999cbuffer', 'E16:') | |
338 else | |
339 call assert_fails('900,999lbuffer', 'E16:') | |
340 endif | |
327 endfunc | 341 endfunc |
328 | 342 |
329 func Test_cbuffer() | 343 func Test_cbuffer() |
330 call XbufferTests('c') | 344 call XbufferTests('c') |
331 call XbufferTests('l') | 345 call XbufferTests('l') |
370 call assert_fails('Xnfile', 'E553') | 384 call assert_fails('Xnfile', 'E553') |
371 Xrewind | 385 Xrewind |
372 call assert_equal('Xqftestfile1', bufname('%')) | 386 call assert_equal('Xqftestfile1', bufname('%')) |
373 call assert_equal(5, line('.')) | 387 call assert_equal(5, line('.')) |
374 | 388 |
389 Xexpr "" | |
390 call assert_fails('Xnext', 'E42:') | |
391 | |
375 call delete('Xqftestfile1') | 392 call delete('Xqftestfile1') |
376 call delete('Xqftestfile2') | 393 call delete('Xqftestfile2') |
377 endfunc | 394 endfunc |
378 | 395 |
379 func Test_browse() | 396 func Test_browse() |
409 let title_text = ':lhelpgrep quickfix' | 426 let title_text = ':lhelpgrep quickfix' |
410 endif | 427 endif |
411 call assert_true(w:quickfix_title =~ title_text, w:quickfix_title) | 428 call assert_true(w:quickfix_title =~ title_text, w:quickfix_title) |
412 " This wipes out the buffer, make sure that doesn't cause trouble. | 429 " This wipes out the buffer, make sure that doesn't cause trouble. |
413 Xclose | 430 Xclose |
431 | |
432 " Search for non existing help string | |
433 call assert_fails('Xhelpgrep a1b2c3', 'E480:') | |
414 endfunc | 434 endfunc |
415 | 435 |
416 func Test_helpgrep() | 436 func Test_helpgrep() |
417 call s:test_xhelpgrep('c') | 437 call s:test_xhelpgrep('c') |
418 helpclose | 438 helpclose |
602 call assert_equal('test://quux.txt', bufferName) | 622 call assert_equal('test://quux.txt', bufferName) |
603 | 623 |
604 wincmd n | only | 624 wincmd n | only |
605 | 625 |
606 augroup! testgroup | 626 augroup! testgroup |
607 endfunc | 627 endfunc |
608 | 628 |
609 func Test_locationlist_curwin_was_closed() | 629 func Test_locationlist_curwin_was_closed() |
610 augroup testgroup | 630 augroup testgroup |
611 au! | 631 au! |
612 autocmd BufReadCmd test_curwin.txt call R(expand("<amatch>")) | 632 autocmd BufReadCmd test_curwin.txt call R(expand("<amatch>")) |
621 call add(q, {'filename': 'test_curwin.txt' }) | 641 call add(q, {'filename': 'test_curwin.txt' }) |
622 call setloclist(0, q) | 642 call setloclist(0, q) |
623 call assert_fails('lrewind', 'E924:') | 643 call assert_fails('lrewind', 'E924:') |
624 | 644 |
625 augroup! testgroup | 645 augroup! testgroup |
626 endfunc | 646 endfunc |
627 | 647 |
628 func Test_locationlist_cross_tab_jump() | 648 func Test_locationlist_cross_tab_jump() |
629 call writefile(['loclistfoo'], 'loclistfoo') | 649 call writefile(['loclistfoo'], 'loclistfoo') |
630 call writefile(['loclistbar'], 'loclistbar') | 650 call writefile(['loclistbar'], 'loclistbar') |
631 set switchbuf=usetab | 651 set switchbuf=usetab |
758 | 778 |
759 let &efm = save_efm | 779 let &efm = save_efm |
760 call delete('Xerrorfile1') | 780 call delete('Xerrorfile1') |
761 call delete('Xerrorfile2') | 781 call delete('Xerrorfile2') |
762 call delete('Xtestfile') | 782 call delete('Xtestfile') |
763 endfunc | 783 endfunc |
764 | 784 |
765 " Test for quickfix directory stack support | 785 " Test for quickfix directory stack support |
766 func s:dir_stack_tests(cchar) | 786 func s:dir_stack_tests(cchar) |
767 call s:setup_commands(a:cchar) | 787 call s:setup_commands(a:cchar) |
768 | 788 |
917 cexpr 'Xtestfile:Line search text' | 937 cexpr 'Xtestfile:Line search text' |
918 let l = getqflist() | 938 let l = getqflist() |
919 call assert_equal(l[0].pattern, '^\VLine search text\$') | 939 call assert_equal(l[0].pattern, '^\VLine search text\$') |
920 call assert_equal(l[0].lnum, 0) | 940 call assert_equal(l[0].lnum, 0) |
921 | 941 |
942 let l = split(execute('clist', ''), "\n") | |
943 call assert_equal([' 1 Xtestfile:^\VLine search text\$: '], l) | |
944 | |
922 " Test for %P, %Q and %t format specifiers | 945 " Test for %P, %Q and %t format specifiers |
923 let lines=["[Xtestfile1]", | 946 let lines=["[Xtestfile1]", |
924 \ "(1,17) error: ';' missing", | 947 \ "(1,17) error: ';' missing", |
925 \ "(21,2) warning: variable 'z' not defined", | 948 \ "(21,2) warning: variable 'z' not defined", |
926 \ "(67,3) error: end of file found before string ended", | 949 \ "(67,3) error: end of file found before string ended", |
950 \ "--", | |
927 \ "", | 951 \ "", |
928 \ "[Xtestfile2]", | 952 \ "[Xtestfile2]", |
953 \ "--", | |
929 \ "", | 954 \ "", |
930 \ "[Xtestfile3]", | 955 \ "[Xtestfile3]", |
931 \ "NEW compiler v1.1", | 956 \ "NEW compiler v1.1", |
932 \ "(2,2) warning: variable 'x' not defined", | 957 \ "(2,2) warning: variable 'x' not defined", |
933 \ "(67,3) warning: 's' already defined" | 958 \ "(67,3) warning: 's' already defined", |
959 \ "--" | |
934 \] | 960 \] |
935 set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q | 961 set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r |
936 " To exercise the push/pop file functionality in quickfix, the test files | 962 " To exercise the push/pop file functionality in quickfix, the test files |
937 " need to be created. | 963 " need to be created. |
938 call writefile(['Line1'], 'Xtestfile1') | 964 call writefile(['Line1'], 'Xtestfile1') |
939 call writefile(['Line2'], 'Xtestfile2') | 965 call writefile(['Line2'], 'Xtestfile2') |
940 call writefile(['Line3'], 'Xtestfile3') | 966 call writefile(['Line3'], 'Xtestfile3') |
941 cexpr "" | 967 cexpr "" |
942 for l in lines | 968 for l in lines |
943 caddexpr l | 969 caddexpr l |
944 endfor | 970 endfor |
945 let l = getqflist() | 971 let l = getqflist() |
946 call assert_equal(9, len(l)) | 972 call assert_equal(12, len(l)) |
947 call assert_equal(21, l[2].lnum) | 973 call assert_equal(21, l[2].lnum) |
948 call assert_equal(2, l[2].col) | 974 call assert_equal(2, l[2].col) |
949 call assert_equal('w', l[2].type) | 975 call assert_equal('w', l[2].type) |
950 call assert_equal('e', l[3].type) | 976 call assert_equal('e', l[3].type) |
951 call delete('Xtestfile1') | 977 call delete('Xtestfile1') |
1096 call assert_equal(5, l[2].lnum) | 1122 call assert_equal(5, l[2].lnum) |
1097 | 1123 |
1098 call g:Xsetlist([]) | 1124 call g:Xsetlist([]) |
1099 let l = g:Xgetlist() | 1125 let l = g:Xgetlist() |
1100 call assert_equal(0, len(l)) | 1126 call assert_equal(0, len(l)) |
1127 | |
1128 " Error cases: | |
1129 " Refer to a non-existing buffer and pass a non-dictionary type | |
1130 call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," . | |
1131 \ " {'bufnr':999, 'lnum':5}])", 'E92:') | |
1132 call g:Xsetlist([[1, 2,3]]) | |
1133 call assert_equal(0, len(g:Xgetlist())) | |
1101 endfunc | 1134 endfunc |
1102 | 1135 |
1103 func Test_setqflist() | 1136 func Test_setqflist() |
1104 new Xtestfile | only | 1137 new Xtestfile | only |
1105 let bnum = bufnr('%') | 1138 let bnum = bufnr('%') |
1114 | 1147 |
1115 func Xlist_empty_middle(cchar) | 1148 func Xlist_empty_middle(cchar) |
1116 call s:setup_commands(a:cchar) | 1149 call s:setup_commands(a:cchar) |
1117 | 1150 |
1118 " create three quickfix lists | 1151 " create three quickfix lists |
1119 Xvimgrep Test_ test_quickfix.vim | 1152 let @/ = 'Test_' |
1153 Xvimgrep // test_quickfix.vim | |
1120 let testlen = len(g:Xgetlist()) | 1154 let testlen = len(g:Xgetlist()) |
1121 call assert_true(testlen > 0) | 1155 call assert_true(testlen > 0) |
1122 Xvimgrep empty test_quickfix.vim | 1156 Xvimgrep empty test_quickfix.vim |
1123 call assert_true(len(g:Xgetlist()) > 0) | 1157 call assert_true(len(g:Xgetlist()) > 0) |
1124 Xvimgrep matches test_quickfix.vim | 1158 Xvimgrep matches test_quickfix.vim |
1607 call assert_equal(['nr'], keys(res)) | 1641 call assert_equal(['nr'], keys(res)) |
1608 | 1642 |
1609 call g:Xsetlist([], ' ', {'title' : 'N3'}) | 1643 call g:Xsetlist([], ' ', {'title' : 'N3'}) |
1610 call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title) | 1644 call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title) |
1611 | 1645 |
1646 " Changing the title of an earlier quickfix list | |
1647 call g:Xsetlist([], ' ', {'title' : 'NewTitle', 'nr' : 2}) | |
1648 call assert_equal('NewTitle', g:Xgetlist({'nr':2, 'title':1}).title) | |
1649 | |
1650 " Changing the title of an invalid quickfix list | |
1651 call assert_equal(-1, g:Xsetlist([], ' ', | |
1652 \ {'title' : 'SomeTitle', 'nr' : 99})) | |
1653 call assert_equal(-1, g:Xsetlist([], ' ', | |
1654 \ {'title' : 'SomeTitle', 'nr' : 'abc'})) | |
1655 | |
1656 if a:cchar == 'c' | |
1657 copen | |
1658 call assert_equal({'winid':win_getid()}, getqflist({'winid':1})) | |
1659 cclose | |
1660 endif | |
1661 | |
1612 " Invalid arguments | 1662 " Invalid arguments |
1613 call assert_fails('call g:Xgetlist([])', 'E715') | 1663 call assert_fails('call g:Xgetlist([])', 'E715') |
1614 call assert_fails('call g:Xsetlist([], "a", [])', 'E715') | 1664 call assert_fails('call g:Xsetlist([], "a", [])', 'E715') |
1615 let s = g:Xsetlist([], 'a', {'abc':1}) | 1665 let s = g:Xsetlist([], 'a', {'abc':1}) |
1616 call assert_equal(-1, s) | 1666 call assert_equal(-1, s) |
1617 | 1667 |
1618 call assert_equal({}, g:Xgetlist({'abc':1})) | 1668 call assert_equal({}, g:Xgetlist({'abc':1})) |
1669 call assert_equal({}, g:Xgetlist({'nr':99, 'title':1})) | |
1670 call assert_equal({}, g:Xgetlist({'nr':[], 'title':1})) | |
1619 | 1671 |
1620 if a:cchar == 'l' | 1672 if a:cchar == 'l' |
1621 call assert_equal({}, getloclist(99, {'title': 1})) | 1673 call assert_equal({}, getloclist(99, {'title': 1})) |
1622 endif | 1674 endif |
1623 endfunc | 1675 endfunc |
1624 | 1676 |
1625 func Test_qf_property() | 1677 func Test_qf_property() |
1626 call Xproperty_tests('c') | 1678 call Xproperty_tests('c') |
1627 call Xproperty_tests('l') | 1679 call Xproperty_tests('l') |
1628 endfunc | 1680 endfunc |
1629 | 1681 |
1630 " Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands | 1682 " Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands |
1631 func QfAutoCmdHandler(loc, cmd) | 1683 func QfAutoCmdHandler(loc, cmd) |
1632 call add(g:acmds, a:loc . a:cmd) | 1684 call add(g:acmds, a:loc . a:cmd) |
1633 endfunc | 1685 endfunc |
1772 call assert_true(winnr() == 1) | 1824 call assert_true(winnr() == 1) |
1773 | 1825 |
1774 enew | only | 1826 enew | only |
1775 set efm&vim | 1827 set efm&vim |
1776 endfunc | 1828 endfunc |
1829 | |
1830 func XvimgrepTests(cchar) | |
1831 call s:setup_commands(a:cchar) | |
1832 | |
1833 call writefile(['Editor:VIM vim', | |
1834 \ 'Editor:Emacs EmAcS', | |
1835 \ 'Editor:Notepad NOTEPAD'], 'Xtestfile1') | |
1836 call writefile(['Linux', 'MacOS', 'MS-Windows'], 'Xtestfile2') | |
1837 | |
1838 " Error cases | |
1839 call assert_fails('Xvimgrep /abc *', 'E682:') | |
1840 | |
1841 let @/='' | |
1842 call assert_fails('Xvimgrep // *', 'E35:') | |
1843 | |
1844 call assert_fails('Xvimgrep abc', 'E683:') | |
1845 call assert_fails('Xvimgrep a1b2c3 Xtestfile1', 'E480:') | |
1846 call assert_fails('Xvimgrep pat Xa1b2c3', 'E480:') | |
1847 | |
1848 Xexpr "" | |
1849 Xvimgrepadd Notepad Xtestfile1 | |
1850 Xvimgrepadd MacOS Xtestfile2 | |
1851 let l = g:Xgetlist() | |
1852 call assert_equal(2, len(l)) | |
1853 call assert_equal('Editor:Notepad NOTEPAD', l[0].text) | |
1854 | |
1855 Xvimgrep #\cvim#g Xtestfile? | |
1856 let l = g:Xgetlist() | |
1857 call assert_equal(2, len(l)) | |
1858 call assert_equal(8, l[0].col) | |
1859 call assert_equal(12, l[1].col) | |
1860 | |
1861 1Xvimgrep ?Editor? Xtestfile* | |
1862 let l = g:Xgetlist() | |
1863 call assert_equal(1, len(l)) | |
1864 call assert_equal('Editor:VIM vim', l[0].text) | |
1865 | |
1866 edit +3 Xtestfile2 | |
1867 Xvimgrep +\cemacs+j Xtestfile1 | |
1868 let l = g:Xgetlist() | |
1869 call assert_equal('Xtestfile2', bufname('')) | |
1870 call assert_equal('Editor:Emacs EmAcS', l[0].text) | |
1871 | |
1872 call delete('Xtestfile1') | |
1873 call delete('Xtestfile2') | |
1874 endfunc | |
1875 | |
1876 " Tests for the :vimgrep command | |
1877 func Test_vimgrep() | |
1878 call XvimgrepTests('c') | |
1879 call XvimgrepTests('l') | |
1880 endfunc |