1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
Tests for the :cdo, :cfdo, :ldo and :lfdo commands
STARTTEST
:so small.vim
:if !has('quickfix') | e! test.ok | wq! test.out | endif
:call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1')
:call writefile(["Line1", "Line2", "Line3"], 'Xtestfile2')
:call writefile(["Line1", "Line2", "Line3"], 'Xtestfile3')
:function RunTests(cchar)
: let nl="\n"
: enew
: " Try with an empty list
: exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Populate the list and then try
: exe a:cchar . "getexpr ['non-error 1', 'Xtestfile1:1:3:Line1', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:3:1:Line3']"
: exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Run command only on selected error lines
: enew
: exe "2,3" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Boundary condition tests
: enew
: exe "1,1" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: enew
: exe "3" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Range test commands
: enew
: exe "%" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: enew
: exe "1,$" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: enew
: exe a:cchar . 'prev'
: exe "." . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Invalid error lines test
: enew
: exe "27" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "4,5" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Run commands from an unsaved buffer
: let v:errmsg=''
: enew
: setlocal modified
: exe "2,2" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: if v:errmsg =~# 'No write since last change'
: let g:result .= 'Unsaved file change test passed' . nl
: else
: let g:result .= 'Unsaved file change test failed' . nl
: endif
: " If the executed command fails, then the operation should be aborted
: enew!
: let subst_count = 0
: exe a:cchar . "do s/Line/xLine/ | let subst_count += 1"
: if subst_count == 1 && getline('.') == 'xLine1'
: let g:result .= 'Abort command on error test passed' . nl
: else
: let g:result .= 'Abort command on error test failed' . nl
: endif
: exe "2,2" . a:cchar . "do! let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " List with no valid error entries
: edit! +2 Xtestfile1
: exe a:cchar . "getexpr ['non-error 1', 'non-error 2', 'non-error 3']"
: exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "2" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: let v:errmsg=''
: exe "%" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "1,$" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "." . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: let g:result .= v:errmsg
: " List with only one valid entry
: exe a:cchar . "getexpr ['Xtestfile3:3:1:Line3']"
: exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " Tests for :cfdo and :lfdo commands
: exe a:cchar . "getexpr ['non-error 1', 'Xtestfile1:1:3:Line1', 'Xtestfile1:2:1:Line2', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:2:3:Line2', 'Xtestfile3:3:1:Line3']"
: exe a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "3" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "2,3" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "%" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe "1,$" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: exe a:cchar . 'pfile'
: exe "." . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
: " List with only one valid entry
: exe a:cchar . "getexpr ['Xtestfile2:2:5:Line2']"
: exe a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C' . nl"
:endfunction
:let result=''
:" Tests for the :cdo quickfix list command
:call RunTests('c')
:let result .= "\n"
:" Tests for the :ldo location list command
:call RunTests('l')
:edit! test.out
:0put =result
:wq!
ENDTEST
|