comparison src/testdir/test_quickfix.vim @ 28421:0e4097e7a714 v8.2.4735

patch 8.2.4735: quickfix tests can be a bit hard to read Commit: https://github.com/vim/vim/commit/4a7724a4406f639edd3f93f3542626811cf56719 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Apr 11 15:11:39 2022 +0100 patch 8.2.4735: quickfix tests can be a bit hard to read Problem: Quickfix tests can be a bit hard to read. Solution: Use heredoc instead of strings and line continuation. (Yegappan Lakshmanan, closes #10145)
author Bram Moolenaar <Bram@vim.org>
date Mon, 11 Apr 2022 16:15:04 +0200
parents 2b595cee4c85
children 45c182c4f7e9
comparison
equal deleted inserted replaced
28420:78d2830c832b 28421:0e4097e7a714
103 Xgetexpr [] 103 Xgetexpr []
104 silent! Xlist 104 silent! Xlist
105 call assert_true(v:errmsg ==# 'E42: No Errors') 105 call assert_true(v:errmsg ==# 'E42: No Errors')
106 106
107 " Populate the list and then try 107 " Populate the list and then try
108 Xgetexpr ['non-error 1', 'Xtestfile1:1:3:Line1', 108 let lines =<< trim END
109 \ 'non-error 2', 'Xtestfile2:2:2:Line2', 109 non-error 1
110 \ 'non-error| 3', 'Xtestfile3:3:1:Line3'] 110 Xtestfile1:1:3:Line1
111 non-error 2
112 Xtestfile2:2:2:Line2
113 non-error| 3
114 Xtestfile3:3:1:Line3
115 END
116 Xgetexpr lines
111 117
112 " List only valid entries 118 " List only valid entries
113 let l = split(execute('Xlist', ''), "\n") 119 let l = split(execute('Xlist', ''), "\n")
114 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', 120 call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
115 \ ' 4 Xtestfile2:2 col 2: Line2', 121 \ ' 4 Xtestfile2:2 col 2: Line2',
263 " Quickfix/Location window should not open with no valid errors 269 " Quickfix/Location window should not open with no valid errors
264 Xwindow 270 Xwindow
265 call assert_true(winnr('$') == 1) 271 call assert_true(winnr('$') == 1)
266 272
267 " Create a list with valid entries 273 " Create a list with valid entries
268 Xgetexpr ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2', 274 let lines =<< trim END
269 \ 'Xtestfile3:3:1:Line3'] 275 Xtestfile1:1:3:Line1
276 Xtestfile2:2:2:Line2
277 Xtestfile3:3:1:Line3
278 END
279 Xgetexpr lines
270 280
271 " Open the window 281 " Open the window
272 Xwindow 282 Xwindow
273 call assert_true(winnr('$') == 2 && winnr() == 2 && 283 call assert_true(winnr('$') == 2 && winnr() == 2 &&
274 \ getline('.') ==# 'Xtestfile1|1 col 3| Line1') 284 \ getline('.') ==# 'Xtestfile1|1 col 3| Line1')
327 Xclose 337 Xclose
328 338
329 if a:cchar == 'c' 339 if a:cchar == 'c'
330 " Opening the quickfix window in multiple tab pages should reuse the 340 " Opening the quickfix window in multiple tab pages should reuse the
331 " quickfix buffer 341 " quickfix buffer
332 Xgetexpr ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2', 342 let lines =<< trim END
333 \ 'Xtestfile3:3:1:Line3'] 343 Xtestfile1:1:3:Line1
344 Xtestfile2:2:2:Line2
345 Xtestfile3:3:1:Line3
346 END
347 Xgetexpr lines
334 Xopen 348 Xopen
335 let qfbufnum = bufnr('%') 349 let qfbufnum = bufnr('%')
336 tabnew 350 tabnew
337 Xopen 351 Xopen
338 call assert_equal(qfbufnum, bufnr('%')) 352 call assert_equal(qfbufnum, bufnr('%'))
363 call assert_equal(height, winheight(0)) 377 call assert_equal(height, winheight(0))
364 quit 378 quit
365 set tabline& showtabline& 379 set tabline& showtabline&
366 endfunc 380 endfunc
367 381
368
369 " Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile 382 " Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile
370 " commands. 383 " commands.
371 func XfileTests(cchar) 384 func XfileTests(cchar)
372 call s:setup_commands(a:cchar) 385 call s:setup_commands(a:cchar)
373 386
374 call writefile(['Xtestfile1:700:10:Line 700', 387 let lines =<< trim END
375 \ 'Xtestfile2:800:15:Line 800'], 'Xqftestfile1') 388 Xtestfile1:700:10:Line 700
389 Xtestfile2:800:15:Line 800
390 END
391 call writefile(lines, 'Xqftestfile1')
376 392
377 enew! 393 enew!
378 Xfile Xqftestfile1 394 Xfile Xqftestfile1
379 let l = g:Xgetlist() 395 let l = g:Xgetlist()
380 call assert_true(len(l) == 2 && 396 call assert_true(len(l) == 2 &&
394 Xaddfile Xqftestfile1 410 Xaddfile Xqftestfile1
395 let l = g:Xgetlist() 411 let l = g:Xgetlist()
396 call assert_true(len(l) == 3 && 412 call assert_true(len(l) == 3 &&
397 \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900') 413 \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900')
398 414
399 call writefile(['Xtestfile1:222:77:Line 222', 415 let lines =<< trim END
400 \ 'Xtestfile2:333:88:Line 333'], 'Xqftestfile1') 416 Xtestfile1:222:77:Line 222
417 Xtestfile2:333:88:Line 333
418 END
419 call writefile(lines, 'Xqftestfile1')
401 420
402 enew! 421 enew!
403 Xgetfile Xqftestfile1 422 Xgetfile Xqftestfile1
404 let l = g:Xgetlist() 423 let l = g:Xgetlist()
405 call assert_true(len(l) == 2 && 424 call assert_true(len(l) == 2 &&
425 " :lgetbuffer commands. 444 " :lgetbuffer commands.
426 func XbufferTests(cchar) 445 func XbufferTests(cchar)
427 call s:setup_commands(a:cchar) 446 call s:setup_commands(a:cchar)
428 447
429 enew! 448 enew!
430 silent! call setline(1, ['Xtestfile7:700:10:Line 700', 449 let lines =<< trim END
431 \ 'Xtestfile8:800:15:Line 800']) 450 Xtestfile7:700:10:Line 700
451 Xtestfile8:800:15:Line 800
452 END
453 silent! call setline(1, lines)
432 Xbuffer! 454 Xbuffer!
433 let l = g:Xgetlist() 455 let l = g:Xgetlist()
434 call assert_true(len(l) == 2 && 456 call assert_true(len(l) == 2 &&
435 \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && 457 \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
436 \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') 458 \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800')
437 459
438 enew! 460 enew!
439 silent! call setline(1, ['Xtestfile9:900:55:Line 900', 461 let lines =<< trim END
440 \ 'Xtestfile10:950:66:Line 950']) 462 Xtestfile9:900:55:Line 900
463 Xtestfile10:950:66:Line 950
464 END
465 silent! call setline(1, lines)
441 Xgetbuffer 466 Xgetbuffer
442 let l = g:Xgetlist() 467 let l = g:Xgetlist()
443 call assert_true(len(l) == 2 && 468 call assert_true(len(l) == 2 &&
444 \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' && 469 \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' &&
445 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950') 470 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950')
446 471
447 enew! 472 enew!
448 silent! call setline(1, ['Xtestfile11:700:20:Line 700', 473 let lines =<< trim END
449 \ 'Xtestfile12:750:25:Line 750']) 474 Xtestfile11:700:20:Line 700
475 Xtestfile12:750:25:Line 750
476 END
477 silent! call setline(1, lines)
450 Xaddbuffer 478 Xaddbuffer
451 let l = g:Xgetlist() 479 let l = g:Xgetlist()
452 call assert_true(len(l) == 4 && 480 call assert_true(len(l) == 4 &&
453 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && 481 \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' &&
454 \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && 482 \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' &&
514 call assert_fails(cmd, 'E42:') 542 call assert_fails(cmd, 'E42:')
515 543
516 call s:create_test_file('Xqftestfile1') 544 call s:create_test_file('Xqftestfile1')
517 call s:create_test_file('Xqftestfile2') 545 call s:create_test_file('Xqftestfile2')
518 546
519 Xgetexpr ['Xqftestfile1:5:Line5', 547 let lines =<< trim END
520 \ 'Xqftestfile1:6:Line6', 548 Xqftestfile1:5:Line5
521 \ 'Xqftestfile2:10:Line10', 549 Xqftestfile1:6:Line6
522 \ 'Xqftestfile2:11:Line11', 550 Xqftestfile2:10:Line10
523 \ 'RegularLine1', 551 Xqftestfile2:11:Line11
524 \ 'RegularLine2'] 552 RegularLine1
553 RegularLine2
554 END
555 Xgetexpr lines
525 556
526 Xfirst 557 Xfirst
527 call assert_fails('-5Xcc', 'E16:') 558 call assert_fails('-5Xcc', 'E16:')
528 call assert_fails('Xprev', 'E553:') 559 call assert_fails('Xprev', 'E553:')
529 call assert_fails('Xpfile', 'E553:') 560 call assert_fails('Xpfile', 'E553:')
569 10Xprev 600 10Xprev
570 call assert_equal('Xqftestfile1', @%) 601 call assert_equal('Xqftestfile1', @%)
571 call assert_equal(5, line('.')) 602 call assert_equal(5, line('.'))
572 603
573 " Jumping to an error from the error window using cc command 604 " Jumping to an error from the error window using cc command
574 Xgetexpr ['Xqftestfile1:5:Line5', 605 let lines =<< trim END
575 \ 'Xqftestfile1:6:Line6', 606 Xqftestfile1:5:Line5
576 \ 'Xqftestfile2:10:Line10', 607 Xqftestfile1:6:Line6
577 \ 'Xqftestfile2:11:Line11'] 608 Xqftestfile2:10:Line10
609 Xqftestfile2:11:Line11
610 END
611 Xgetexpr lines
578 Xopen 612 Xopen
579 10Xcc 613 10Xcc
580 call assert_equal(11, line('.')) 614 call assert_equal(11, line('.'))
581 call assert_equal('Xqftestfile2', @%) 615 call assert_equal('Xqftestfile2', @%)
582 Xopen 616 Xopen
1277 call s:setup_commands(a:cchar) 1311 call s:setup_commands(a:cchar)
1278 1312
1279 let save_efm=&efm 1313 let save_efm=&efm
1280 set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' 1314 set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
1281 1315
1282 let lines = ["Entering dir 'dir1/a'", 1316 let lines =<< trim END
1283 \ 'habits2.txt:1:Nine Healthy Habits', 1317 Entering dir 'dir1/a'
1284 \ "Entering dir 'b'", 1318 habits2.txt:1:Nine Healthy Habits
1285 \ 'habits3.txt:2:0 Hours of television', 1319 Entering dir 'b'
1286 \ 'habits2.txt:7:5 Small meals', 1320 habits3.txt:2:0 Hours of television
1287 \ "Entering dir 'dir1/c'", 1321 habits2.txt:7:5 Small meals
1288 \ 'habits4.txt:3:1 Hour of exercise', 1322 Entering dir 'dir1/c'
1289 \ "Leaving dir 'dir1/c'", 1323 habits4.txt:3:1 Hour of exercise
1290 \ "Leaving dir 'dir1/a'", 1324 Leaving dir 'dir1/c'
1291 \ 'habits1.txt:4:2 Liters of water', 1325 Leaving dir 'dir1/a'
1292 \ "Entering dir 'dir2'", 1326 habits1.txt:4:2 Liters of water
1293 \ 'habits5.txt:5:3 Cups of hot green tea', 1327 Entering dir 'dir2'
1294 \ "Leaving dir 'dir2'" 1328 habits5.txt:5:3 Cups of hot green tea
1295 \] 1329 Leaving dir 'dir2'
1330 END
1296 1331
1297 Xexpr "" 1332 Xexpr ""
1298 for l in lines 1333 for l in lines
1299 Xaddexpr l 1334 Xaddexpr l
1300 endfor 1335 endfor
1324 call mkdir('dir1/a') 1359 call mkdir('dir1/a')
1325 call mkdir('dir1/a/b') 1360 call mkdir('dir1/a/b')
1326 call mkdir('dir1/c') 1361 call mkdir('dir1/c')
1327 call mkdir('dir2') 1362 call mkdir('dir2')
1328 1363
1329 let lines = ["Nine Healthy Habits", 1364 let lines =<< trim END
1330 \ "0 Hours of television", 1365 Nine Healthy Habits
1331 \ "1 Hour of exercise", 1366 0 Hours of television
1332 \ "2 Liters of water", 1367 1 Hour of exercise
1333 \ "3 Cups of hot green tea", 1368 2 Liters of water
1334 \ "4 Short mental breaks", 1369 3 Cups of hot green tea
1335 \ "5 Small meals", 1370 4 Short mental breaks
1336 \ "6 AM wake up time", 1371 5 Small meals
1337 \ "7 Minutes of laughter", 1372 6 AM wake up time
1338 \ "8 Hours of sleep (at least)", 1373 7 Minutes of laughter
1339 \ "9 PM end of the day and off to bed" 1374 8 Hours of sleep (at least)
1340 \ ] 1375 9 PM end of the day and off to bed
1376 END
1341 call writefile(lines, 'habits1.txt') 1377 call writefile(lines, 'habits1.txt')
1342 call writefile(lines, 'dir1/a/habits2.txt') 1378 call writefile(lines, 'dir1/a/habits2.txt')
1343 call writefile(lines, 'dir1/a/b/habits3.txt') 1379 call writefile(lines, 'dir1/a/b/habits3.txt')
1344 call writefile(lines, 'dir1/c/habits4.txt') 1380 call writefile(lines, 'dir1/c/habits4.txt')
1345 call writefile(lines, 'dir2/habits5.txt') 1381 call writefile(lines, 'dir2/habits5.txt')
1361 let &efm = 1397 let &efm =
1362 \ '%Eerror %m %l,' . 1398 \ '%Eerror %m %l,' .
1363 \ '%-Wignored %m %l,' . 1399 \ '%-Wignored %m %l,' .
1364 \ '%+Cmore ignored %m %l,' . 1400 \ '%+Cmore ignored %m %l,' .
1365 \ '%Zignored end' 1401 \ '%Zignored end'
1366 Xgetexpr ['ignored warning 1', 'more ignored continuation 2', 'ignored end', 'error resync 4'] 1402 let lines =<< trim END
1403 ignored warning 1
1404 more ignored continuation 2
1405 ignored end
1406 error resync 4
1407 END
1408 Xgetexpr lines
1367 let l = map(g:Xgetlist(), '[v:val.text, v:val.valid, v:val.lnum, v:val.type]') 1409 let l = map(g:Xgetlist(), '[v:val.text, v:val.valid, v:val.lnum, v:val.type]')
1368 call assert_equal([['resync', 1, 4, 'E']], l) 1410 call assert_equal([['resync', 1, 4, 'E']], l)
1369 1411
1370 let &efm = save_efm 1412 let &efm = save_efm
1371 endfunc 1413 endfunc
1604 func Test_efm_error_type() 1646 func Test_efm_error_type()
1605 let save_efm = &efm 1647 let save_efm = &efm
1606 1648
1607 " error type 1649 " error type
1608 set efm=%f:%l:%t:%m 1650 set efm=%f:%l:%t:%m
1609 cexpr ["Xfile1:10:E:msg1", "Xfile1:20:W:msg2", "Xfile1:30:I:msg3", 1651 let lines =<< trim END
1610 \ "Xfile1:40:N:msg4", "Xfile1:50:R:msg5"] 1652 Xfile1:10:E:msg1
1653 Xfile1:20:W:msg2
1654 Xfile1:30:I:msg3
1655 Xfile1:40:N:msg4
1656 Xfile1:50:R:msg5
1657 END
1658 cexpr lines
1611 let output = split(execute('clist'), "\n") 1659 let output = split(execute('clist'), "\n")
1612 call assert_equal([ 1660 call assert_equal([
1613 \ ' 1 Xfile1:10 error: msg1', 1661 \ ' 1 Xfile1:10 error: msg1',
1614 \ ' 2 Xfile1:20 warning: msg2', 1662 \ ' 2 Xfile1:20 warning: msg2',
1615 \ ' 3 Xfile1:30 info: msg3', 1663 \ ' 3 Xfile1:30 info: msg3',
1616 \ ' 4 Xfile1:40 note: msg4', 1664 \ ' 4 Xfile1:40 note: msg4',
1617 \ ' 5 Xfile1:50 R: msg5'], output) 1665 \ ' 5 Xfile1:50 R: msg5'], output)
1618 1666
1619 " error type and a error number 1667 " error type and a error number
1620 set efm=%f:%l:%t:%n:%m 1668 set efm=%f:%l:%t:%n:%m
1621 cexpr ["Xfile1:10:E:2:msg1", "Xfile1:20:W:4:msg2", "Xfile1:30:I:6:msg3", 1669 let lines =<< trim END
1622 \ "Xfile1:40:N:8:msg4", "Xfile1:50:R:3:msg5"] 1670 Xfile1:10:E:2:msg1
1671 Xfile1:20:W:4:msg2
1672 Xfile1:30:I:6:msg3
1673 Xfile1:40:N:8:msg4
1674 Xfile1:50:R:3:msg5
1675 END
1676 cexpr lines
1623 let output = split(execute('clist'), "\n") 1677 let output = split(execute('clist'), "\n")
1624 call assert_equal([ 1678 call assert_equal([
1625 \ ' 1 Xfile1:10 error 2: msg1', 1679 \ ' 1 Xfile1:10 error 2: msg1',
1626 \ ' 2 Xfile1:20 warning 4: msg2', 1680 \ ' 2 Xfile1:20 warning 4: msg2',
1627 \ ' 3 Xfile1:30 info 6: msg3', 1681 \ ' 3 Xfile1:30 info 6: msg3',
1642 \ ' 1 Xfile1:10-20 col 1-2 error: msg1', 1696 \ ' 1 Xfile1:10-20 col 1-2 error: msg1',
1643 \ ' 2 Xfile1:20-30 col 2-3 warning: msg2'], output) 1697 \ ' 2 Xfile1:20-30 col 2-3 warning: msg2'], output)
1644 1698
1645 " multiple lines 1699 " multiple lines
1646 set efm=%A%n)%m,%Z%f:%l-%e:%c-%k 1700 set efm=%A%n)%m,%Z%f:%l-%e:%c-%k
1647 cexpr ["1)msg1", "Xfile1:14-24:1-2", 1701 let lines =<< trim END
1648 \ "2)msg2", "Xfile1:24-34:3-4"] 1702 1)msg1
1703 Xfile1:14-24:1-2
1704 2)msg2
1705 Xfile1:24-34:3-4
1706 END
1707 cexpr lines
1649 let output = split(execute('clist'), "\n") 1708 let output = split(execute('clist'), "\n")
1650 call assert_equal([ 1709 call assert_equal([
1651 \ ' 1 Xfile1:14-24 col 1-2 error 1: msg1', 1710 \ ' 1 Xfile1:14-24 col 1-2 error 1: msg1',
1652 \ ' 2 Xfile1:24-34 col 3-4 error 2: msg2'], output) 1711 \ ' 2 Xfile1:24-34 col 3-4 error 2: msg2'], output)
1653 let &efm = save_efm 1712 let &efm = save_efm
2053 2112
2054 func Test_cgetfile_on_long_lines() 2113 func Test_cgetfile_on_long_lines()
2055 " Problematic values if the line is longer than 4096 bytes. Then 1024 bytes 2114 " Problematic values if the line is longer than 4096 bytes. Then 1024 bytes
2056 " are read at a time. 2115 " are read at a time.
2057 for len in [4078, 4079, 4080, 5102, 5103, 5104, 6126, 6127, 6128, 7150, 7151, 7152] 2116 for len in [4078, 4079, 4080, 5102, 5103, 5104, 6126, 6127, 6128, 7150, 7151, 7152]
2058 let lines = [ 2117 let lines =<< trim END
2059 \ '/tmp/file1:1:1:aaa', 2118 /tmp/file1:1:1:aaa
2060 \ '/tmp/file2:1:1:%s', 2119 /tmp/file2:1:1:%s
2061 \ '/tmp/file3:1:1:bbb', 2120 /tmp/file3:1:1:bbb
2062 \ '/tmp/file4:1:1:ccc', 2121 /tmp/file4:1:1:ccc
2063 \ ] 2122 END
2064 let lines[1] = substitute(lines[1], '%s', repeat('x', len), '') 2123 let lines[1] = substitute(lines[1], '%s', repeat('x', len), '')
2065 call writefile(lines, 'Xcqetfile.txt') 2124 call writefile(lines, 'Xcqetfile.txt')
2066 cgetfile Xcqetfile.txt 2125 cgetfile Xcqetfile.txt
2067 call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len) 2126 call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len)
2068 endfor 2127 endfor
2085 new | only 2144 new | only
2086 edit Xqftestfile1 2145 edit Xqftestfile1
2087 let file1_winid = win_getid() 2146 let file1_winid = win_getid()
2088 new Xqftestfile2 2147 new Xqftestfile2
2089 let file2_winid = win_getid() 2148 let file2_winid = win_getid()
2090 cgetexpr ['Xqftestfile1:5:Line5', 2149 let lines =<< trim END
2091 \ 'Xqftestfile1:6:Line6', 2150 Xqftestfile1:5:Line5
2092 \ 'Xqftestfile2:10:Line10', 2151 Xqftestfile1:6:Line6
2093 \ 'Xqftestfile2:11:Line11', 2152 Xqftestfile2:10:Line10
2094 \ 'Xqftestfile3:15:Line15', 2153 Xqftestfile2:11:Line11
2095 \ 'Xqftestfile3:16:Line16'] 2154 Xqftestfile3:15:Line15
2155 Xqftestfile3:16:Line16
2156 END
2157 cgetexpr lines
2096 2158
2097 new 2159 new
2098 let winid = win_getid() 2160 let winid = win_getid()
2099 cfirst | cnext 2161 cfirst | cnext
2100 call assert_equal(winid, win_getid()) 2162 call assert_equal(winid, win_getid())
2758 caddexpr "" 2820 caddexpr ""
2759 cgetexpr "" 2821 cgetexpr ""
2760 silent! cexpr non_existing_func() 2822 silent! cexpr non_existing_func()
2761 silent! caddexpr non_existing_func() 2823 silent! caddexpr non_existing_func()
2762 silent! cgetexpr non_existing_func() 2824 silent! cgetexpr non_existing_func()
2763 let l = ['precexpr', 2825 let l =<< trim END
2764 \ 'postcexpr', 2826 precexpr
2765 \ 'precaddexpr', 2827 postcexpr
2766 \ 'postcaddexpr', 2828 precaddexpr
2767 \ 'precgetexpr', 2829 postcaddexpr
2768 \ 'postcgetexpr', 2830 precgetexpr
2769 \ 'precexpr', 2831 postcgetexpr
2770 \ 'postcexpr', 2832 precexpr
2771 \ 'precaddexpr', 2833 postcexpr
2772 \ 'postcaddexpr', 2834 precaddexpr
2773 \ 'precgetexpr', 2835 postcaddexpr
2774 \ 'postcgetexpr', 2836 precgetexpr
2775 \ 'precexpr', 2837 postcgetexpr
2776 \ 'precaddexpr', 2838 precexpr
2777 \ 'precgetexpr'] 2839 precaddexpr
2840 precgetexpr
2841 END
2778 call assert_equal(l, g:acmds) 2842 call assert_equal(l, g:acmds)
2779 2843
2780 let g:acmds = [] 2844 let g:acmds = []
2781 enew! | call append(0, "F2:10:Line 10") 2845 enew! | call append(0, "F2:10:Line 10")
2782 cbuffer! 2846 cbuffer!
2789 bunload 2853 bunload
2790 exe 'silent! cbuffer! ' . bnum 2854 exe 'silent! cbuffer! ' . bnum
2791 exe 'silent! cgetbuffer ' . bnum 2855 exe 'silent! cgetbuffer ' . bnum
2792 exe 'silent! caddbuffer ' . bnum 2856 exe 'silent! caddbuffer ' . bnum
2793 enew! 2857 enew!
2794 let l = ['precbuffer', 2858 let l =<< trim END
2795 \ 'postcbuffer', 2859 precbuffer
2796 \ 'precgetbuffer', 2860 postcbuffer
2797 \ 'postcgetbuffer', 2861 precgetbuffer
2798 \ 'precaddbuffer', 2862 postcgetbuffer
2799 \ 'postcaddbuffer', 2863 precaddbuffer
2800 \ 'precbuffer', 2864 postcaddbuffer
2801 \ 'precgetbuffer', 2865 precbuffer
2802 \ 'precaddbuffer'] 2866 precgetbuffer
2867 precaddbuffer
2868 END
2803 call assert_equal(l, g:acmds) 2869 call assert_equal(l, g:acmds)
2804 2870
2805 call writefile(['Xtest:1:Line1'], 'Xtest') 2871 call writefile(['Xtest:1:Line1'], 'Xtest')
2806 call writefile([], 'Xempty') 2872 call writefile([], 'Xempty')
2807 let g:acmds = [] 2873 let g:acmds = []
2812 caddfile Xempty 2878 caddfile Xempty
2813 cgetfile Xempty 2879 cgetfile Xempty
2814 silent! cfile do_not_exist 2880 silent! cfile do_not_exist
2815 silent! caddfile do_not_exist 2881 silent! caddfile do_not_exist
2816 silent! cgetfile do_not_exist 2882 silent! cgetfile do_not_exist
2817 let l = ['precfile', 2883 let l =<< trim END
2818 \ 'postcfile', 2884 precfile
2819 \ 'precaddfile', 2885 postcfile
2820 \ 'postcaddfile', 2886 precaddfile
2821 \ 'precgetfile', 2887 postcaddfile
2822 \ 'postcgetfile', 2888 precgetfile
2823 \ 'precfile', 2889 postcgetfile
2824 \ 'postcfile', 2890 precfile
2825 \ 'precaddfile', 2891 postcfile
2826 \ 'postcaddfile', 2892 precaddfile
2827 \ 'precgetfile', 2893 postcaddfile
2828 \ 'postcgetfile', 2894 precgetfile
2829 \ 'precfile', 2895 postcgetfile
2830 \ 'postcfile', 2896 precfile
2831 \ 'precaddfile', 2897 postcfile
2832 \ 'postcaddfile', 2898 precaddfile
2833 \ 'precgetfile', 2899 postcaddfile
2834 \ 'postcgetfile'] 2900 precgetfile
2901 postcgetfile
2902 END
2835 call assert_equal(l, g:acmds) 2903 call assert_equal(l, g:acmds)
2836 2904
2837 let g:acmds = [] 2905 let g:acmds = []
2838 helpgrep quickfix 2906 helpgrep quickfix
2839 silent! helpgrep non_existing_help_topic 2907 silent! helpgrep non_existing_help_topic
2842 silent! vimgrep non_existing_test Xtest 2910 silent! vimgrep non_existing_test Xtest
2843 silent! vimgrepadd non_existing_test Xtest 2911 silent! vimgrepadd non_existing_test Xtest
2844 set makeprg= 2912 set makeprg=
2845 silent! make 2913 silent! make
2846 set makeprg& 2914 set makeprg&
2847 let l = ['prehelpgrep', 2915 let l =<< trim END
2848 \ 'posthelpgrep', 2916 prehelpgrep
2849 \ 'prehelpgrep', 2917 posthelpgrep
2850 \ 'posthelpgrep', 2918 prehelpgrep
2851 \ 'previmgrep', 2919 posthelpgrep
2852 \ 'postvimgrep', 2920 previmgrep
2853 \ 'previmgrepadd', 2921 postvimgrep
2854 \ 'postvimgrepadd', 2922 previmgrepadd
2855 \ 'previmgrep', 2923 postvimgrepadd
2856 \ 'postvimgrep', 2924 previmgrep
2857 \ 'previmgrepadd', 2925 postvimgrep
2858 \ 'postvimgrepadd', 2926 previmgrepadd
2859 \ 'premake', 2927 postvimgrepadd
2860 \ 'postmake'] 2928 premake
2929 postmake
2930 END
2861 call assert_equal(l, g:acmds) 2931 call assert_equal(l, g:acmds)
2862 2932
2863 if has('unix') 2933 if has('unix')
2864 " Run this test only on Unix-like systems. The grepprg may not be set on 2934 " Run this test only on Unix-like systems. The grepprg may not be set on
2865 " non-Unix systems. 2935 " non-Unix systems.
2875 silent grep Grep_Autocmd_Text test_quickfix.vim 2945 silent grep Grep_Autocmd_Text test_quickfix.vim
2876 silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim 2946 silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim
2877 silent lgrep Grep_Autocmd_Text test_quickfix.vim 2947 silent lgrep Grep_Autocmd_Text test_quickfix.vim
2878 silent lgrepadd GrepAdd_Autocmd_Text test_quickfix.vim 2948 silent lgrepadd GrepAdd_Autocmd_Text test_quickfix.vim
2879 set grepprg&vim 2949 set grepprg&vim
2880 let l = ['pregrep', 2950 let l =<< trim END
2881 \ 'postgrep', 2951 pregrep
2882 \ 'pregrepadd', 2952 postgrep
2883 \ 'postgrepadd', 2953 pregrepadd
2884 \ 'pregrep', 2954 postgrepadd
2885 \ 'postgrep', 2955 pregrep
2886 \ 'pregrepadd', 2956 postgrep
2887 \ 'postgrepadd', 2957 pregrepadd
2888 \ 'pregrep', 2958 postgrepadd
2889 \ 'postgrep', 2959 pregrep
2890 \ 'pregrepadd', 2960 postgrep
2891 \ 'postgrepadd', 2961 pregrepadd
2892 \ 'prelgrep', 2962 postgrepadd
2893 \ 'postlgrep', 2963 prelgrep
2894 \ 'prelgrepadd', 2964 postlgrep
2895 \ 'postlgrepadd'] 2965 prelgrepadd
2966 postlgrepadd
2967 END
2896 call assert_equal(l, g:acmds) 2968 call assert_equal(l, g:acmds)
2897 endif 2969 endif
2898 2970
2899 call delete('Xtest') 2971 call delete('Xtest')
2900 call delete('Xempty') 2972 call delete('Xempty')
3049 3121
3050 func Test_cwindow_highlight() 3122 func Test_cwindow_highlight()
3051 CheckScreendump 3123 CheckScreendump
3052 3124
3053 let lines =<< trim END 3125 let lines =<< trim END
3054 call setline(1, ['some', 'text', 'with', 'matches']) 3126 call setline(1, ['some', 'text', 'with', 'matches'])
3055 write XCwindow 3127 write XCwindow
3056 vimgrep e XCwindow 3128 vimgrep e XCwindow
3057 redraw 3129 redraw
3058 cwindow 4 3130 cwindow 4
3059 END 3131 END
3060 call writefile(lines, 'XtestCwindow') 3132 call writefile(lines, 'XtestCwindow')
3061 let buf = RunVimInTerminal('-S XtestCwindow', #{rows: 12}) 3133 let buf = RunVimInTerminal('-S XtestCwindow', #{rows: 12})
3062 call VerifyScreenDump(buf, 'Test_quickfix_cwindow_1', {}) 3134 call VerifyScreenDump(buf, 'Test_quickfix_cwindow_1', {})
3063 3135
3071 endfunc 3143 endfunc
3072 3144
3073 func XvimgrepTests(cchar) 3145 func XvimgrepTests(cchar)
3074 call s:setup_commands(a:cchar) 3146 call s:setup_commands(a:cchar)
3075 3147
3076 call writefile(['Editor:VIM vim', 3148 let lines =<< trim END
3077 \ 'Editor:Emacs EmAcS', 3149 Editor:VIM vim
3078 \ 'Editor:Notepad NOTEPAD'], 'Xtestfile1') 3150 Editor:Emacs EmAcS
3151 Editor:Notepad NOTEPAD
3152 END
3153 call writefile(lines, 'Xtestfile1')
3079 call writefile(['Linux', 'macOS', 'MS-Windows'], 'Xtestfile2') 3154 call writefile(['Linux', 'macOS', 'MS-Windows'], 'Xtestfile2')
3080 3155
3081 " Error cases 3156 " Error cases
3082 call assert_fails('Xvimgrep /abc *', 'E682:') 3157 call assert_fails('Xvimgrep /abc *', 'E682:')
3083 3158
3583 3658
3584 " Test for start of a new error line in the same line where a previous 3659 " Test for start of a new error line in the same line where a previous
3585 " error line ends with a file stack. 3660 " error line ends with a file stack.
3586 let efm_val = 'Error\ l%l\ in\ %f,' 3661 let efm_val = 'Error\ l%l\ in\ %f,'
3587 let efm_val .= '%-P%>(%f%r,Error\ l%l\ in\ %m,%-Q)%r' 3662 let efm_val .= '%-P%>(%f%r,Error\ l%l\ in\ %m,%-Q)%r'
3588 let l = g:Xgetlist({'lines' : [ 3663 let lines =<< trim END
3589 \ '(one.txt', 3664 (one.txt
3590 \ 'Error l4 in one.txt', 3665 Error l4 in one.txt
3591 \ ') (two.txt', 3666 ) (two.txt
3592 \ 'Error l6 in two.txt', 3667 Error l6 in two.txt
3593 \ ')', 3668 )
3594 \ 'Error l8 in one.txt' 3669 Error l8 in one.txt
3595 \ ], 'efm' : efm_val}) 3670 END
3671 let l = g:Xgetlist({'lines': lines, 'efm' : efm_val})
3596 call assert_equal(3, len(l.items)) 3672 call assert_equal(3, len(l.items))
3597 call assert_equal('one.txt', bufname(l.items[0].bufnr)) 3673 call assert_equal('one.txt', bufname(l.items[0].bufnr))
3598 call assert_equal(4, l.items[0].lnum) 3674 call assert_equal(4, l.items[0].lnum)
3599 call assert_equal('one.txt', l.items[0].text) 3675 call assert_equal('one.txt', l.items[0].text)
3600 call assert_equal('two.txt', bufname(l.items[1].bufnr)) 3676 call assert_equal('two.txt', bufname(l.items[1].bufnr))
3868 " no usable windows are available, then a new window should be opened. 3944 " no usable windows are available, then a new window should be opened.
3869 enew! | new | only 3945 enew! | new | only
3870 call g:Xsetlist([], 'f') 3946 call g:Xsetlist([], 'f')
3871 setlocal buftype=nofile 3947 setlocal buftype=nofile
3872 new 3948 new
3873 call g:Xsetlist([], ' ', {'lines' : ['F1:1:1:Line1', 'F1:2:2:Line2', 'F2:1:1:Line1', 'F2:2:2:Line2', 'F3:1:1:Line1', 'F3:2:2:Line2']}) 3949 let lines =<< trim END
3950 F1:1:1:Line1
3951 F1:2:2:Line2
3952 F2:1:1:Line1
3953 F2:2:2:Line2
3954 F3:1:1:Line1
3955 F3:2:2:Line2
3956 END
3957 call g:Xsetlist([], ' ', {'lines': lines})
3874 Xopen 3958 Xopen
3875 let winid = win_getid() 3959 let winid = win_getid()
3876 wincmd p 3960 wincmd p
3877 close 3961 close
3878 call win_gotoid(winid) 3962 call win_gotoid(winid)
5094 call assert_fails('Xafter', 'E776:') 5178 call assert_fails('Xafter', 'E776:')
5095 close 5179 close
5096 endif 5180 endif
5097 5181
5098 " Test for lines with multiple quickfix entries 5182 " Test for lines with multiple quickfix entries
5099 Xexpr ["X1:5:L5", "X2:5:1:L5_1", "X2:5:2:L5_2", "X2:5:3:L5_3", 5183 let lines =<< trim END
5100 \ "X2:10:1:L10_1", "X2:10:2:L10_2", "X2:10:3:L10_3", 5184 X1:5:L5
5101 \ "X2:15:1:L15_1", "X2:15:2:L15_2", "X2:15:3:L15_3", "X3:3:L3"] 5185 X2:5:1:L5_1
5186 X2:5:2:L5_2
5187 X2:5:3:L5_3
5188 X2:10:1:L10_1
5189 X2:10:2:L10_2
5190 X2:10:3:L10_3
5191 X2:15:1:L15_1
5192 X2:15:2:L15_2
5193 X2:15:3:L15_3
5194 X3:3:L3
5195 END
5196 Xexpr lines
5102 edit +1 X2 5197 edit +1 X2
5103 Xbelow 2 5198 Xbelow 2
5104 call assert_equal(['X2', 10, 1], [@%, line('.'), col('.')]) 5199 call assert_equal(['X2', 10, 1], [@%, line('.'), col('.')])
5105 normal 1G 5200 normal 1G
5106 Xafter 2 5201 Xafter 2
5160 call Xtest_below('c') 5255 call Xtest_below('c')
5161 call Xtest_below('l') 5256 call Xtest_below('l')
5162 endfunc 5257 endfunc
5163 5258
5164 func Test_quickfix_count() 5259 func Test_quickfix_count()
5165 let commands = [ 5260 let commands =<< trim END
5166 \ 'cNext', 5261 cNext
5167 \ 'cNfile', 5262 cNfile
5168 \ 'cabove', 5263 cabove
5169 \ 'cbelow', 5264 cbelow
5170 \ 'cfirst', 5265 cfirst
5171 \ 'clast', 5266 clast
5172 \ 'cnewer', 5267 cnewer
5173 \ 'cnext', 5268 cnext
5174 \ 'cnfile', 5269 cnfile
5175 \ 'colder', 5270 colder
5176 \ 'cprevious', 5271 cprevious
5177 \ 'crewind', 5272 crewind
5178 \ 5273 lNext
5179 \ 'lNext', 5274 lNfile
5180 \ 'lNfile', 5275 labove
5181 \ 'labove', 5276 lbelow
5182 \ 'lbelow', 5277 lfirst
5183 \ 'lfirst', 5278 llast
5184 \ 'llast', 5279 lnewer
5185 \ 'lnewer', 5280 lnext
5186 \ 'lnext', 5281 lnfile
5187 \ 'lnfile', 5282 lolder
5188 \ 'lolder', 5283 lprevious
5189 \ 'lprevious', 5284 lrewind
5190 \ 'lrewind', 5285 END
5191 \ ]
5192 for cmd in commands 5286 for cmd in commands
5193 call assert_fails('-1' .. cmd, 'E16:') 5287 call assert_fails('-1' .. cmd, 'E16:')
5194 call assert_fails('.' .. cmd, 'E16:') 5288 call assert_fails('.' .. cmd, 'E16:')
5195 call assert_fails('%' .. cmd, 'E16:') 5289 call assert_fails('%' .. cmd, 'E16:')
5196 call assert_fails('$' .. cmd, 'E16:') 5290 call assert_fails('$' .. cmd, 'E16:')
6008 call s:create_test_file('Xqftestfile2') 6102 call s:create_test_file('Xqftestfile2')
6009 call s:create_test_file('Xqftestfile3') 6103 call s:create_test_file('Xqftestfile3')
6010 6104
6011 %bwipe! 6105 %bwipe!
6012 6106
6013 lgetexpr ['Xqftestfile1:5:Line5', 6107 let lines =<< trim END
6014 \ 'Xqftestfile2:10:Line10', 6108 Xqftestfile1:5:Line5
6015 \ 'Xqftestfile3:16:Line16'] 6109 Xqftestfile2:10:Line10
6110 Xqftestfile3:16:Line16
6111 END
6112 lgetexpr lines
6016 6113
6017 silent! llast 6114 silent! llast
6018 call assert_equal(1, tabpagenr('$')) 6115 call assert_equal(1, tabpagenr('$'))
6019 call assert_equal('Xqftestfile3', bufname()) 6116 call assert_equal('Xqftestfile3', bufname())
6020 6117