Mercurial > vim
comparison src/testdir/test_cscope.vim @ 13950:741b1feeac9f v8.0.1845
patch 8.0.1845: various comment updates needed, missing white space
commit https://github.com/vim/vim/commit/259f26ac2d41ecfb28b82c651b2bfc1edc7c3e29
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 15 22:25:40 2018 +0200
patch 8.0.1845: various comment updates needed, missing white space
Problem: Various comment updates needed, missing white space.
Solution: Update comments, add white space.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 15 May 2018 22:30:07 +0200 |
parents | 1c4ebbae41d2 |
children | 72afa7268670 |
comparison
equal
deleted
inserted
replaced
13949:a607f9751fee | 13950:741b1feeac9f |
---|---|
34 call assert_fails('cscope add Xcscope.out', 'E568') | 34 call assert_fails('cscope add Xcscope.out', 'E568') |
35 call assert_fails('cscope add doesnotexist.out', 'E563') | 35 call assert_fails('cscope add doesnotexist.out', 'E563') |
36 | 36 |
37 " Test 1: Find this C-Symbol | 37 " Test 1: Find this C-Symbol |
38 for cmd in ['cs find s main', 'cs find 0 main'] | 38 for cmd in ['cs find s main', 'cs find 0 main'] |
39 let a=execute(cmd) | 39 let a = execute(cmd) |
40 " Test 1.1 test where it moves the cursor | 40 " Test 1.1 test where it moves the cursor |
41 call assert_equal('main(void)', getline('.')) | 41 call assert_equal('main(void)', getline('.')) |
42 " Test 1.2 test the output of the :cs command | 42 " Test 1.2 test the output of the :cs command |
43 call assert_match('\n(1 of 1): <<main>> main(void )', a) | 43 call assert_match('\n(1 of 1): <<main>> main(void )', a) |
44 endfor | 44 endfor |
49 call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1)) | 49 call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1)) |
50 endfor | 50 endfor |
51 | 51 |
52 " Test 3: Find functions called by this function | 52 " Test 3: Find functions called by this function |
53 for cmd in ['cs find d test_mf_hash', 'cs find 2 test_mf_hash'] | 53 for cmd in ['cs find d test_mf_hash', 'cs find 2 test_mf_hash'] |
54 let a=execute(cmd) | 54 let a = execute(cmd) |
55 call assert_match('\n(1 of 42): <<mf_hash_init>> mf_hash_init(&ht);', a) | 55 call assert_match('\n(1 of 42): <<mf_hash_init>> mf_hash_init(&ht);', a) |
56 call assert_equal(' mf_hash_init(&ht);', getline('.')) | 56 call assert_equal(' mf_hash_init(&ht);', getline('.')) |
57 endfor | 57 endfor |
58 | 58 |
59 " Test 4: Find functions calling this function | 59 " Test 4: Find functions calling this function |
60 for cmd in ['cs find c test_mf_hash', 'cs find 3 test_mf_hash'] | 60 for cmd in ['cs find c test_mf_hash', 'cs find 3 test_mf_hash'] |
61 let a=execute(cmd) | 61 let a = execute(cmd) |
62 call assert_match('\n(1 of 1): <<main>> test_mf_hash();', a) | 62 call assert_match('\n(1 of 1): <<main>> test_mf_hash();', a) |
63 call assert_equal(' test_mf_hash();', getline('.')) | 63 call assert_equal(' test_mf_hash();', getline('.')) |
64 endfor | 64 endfor |
65 | 65 |
66 " Test 5: Find this text string | 66 " Test 5: Find this text string |
67 for cmd in ['cs find t Bram', 'cs find 4 Bram'] | 67 for cmd in ['cs find t Bram', 'cs find 4 Bram'] |
68 let a=execute(cmd) | 68 let a = execute(cmd) |
69 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) | 69 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) |
70 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) | 70 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) |
71 endfor | 71 endfor |
72 | 72 |
73 " Test 6: Find this egrep pattern | 73 " Test 6: Find this egrep pattern |
74 " test all matches returned by cscope | 74 " test all matches returned by cscope |
75 for cmd in ['cs find e ^\#includ.', 'cs find 6 ^\#includ.'] | 75 for cmd in ['cs find e ^\#includ.', 'cs find 6 ^\#includ.'] |
76 let a=execute(cmd) | 76 let a = execute(cmd) |
77 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a) | 77 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a) |
78 call assert_equal('#include <assert.h>', getline('.')) | 78 call assert_equal('#include <assert.h>', getline('.')) |
79 cnext | 79 cnext |
80 call assert_equal('#include "main.c"', getline('.')) | 80 call assert_equal('#include "main.c"', getline('.')) |
81 cnext | 81 cnext |
82 call assert_equal('#include "memfile.c"', getline('.')) | 82 call assert_equal('#include "memfile.c"', getline('.')) |
83 call assert_fails('cnext', 'E553:') | 83 call assert_fails('cnext', 'E553:') |
84 endfor | 84 endfor |
85 | 85 |
86 " Test 7: Find the same egrep pattern using lcscope this time. | 86 " Test 7: Find the same egrep pattern using lcscope this time. |
87 let a=execute('lcs find e ^\#includ.') | 87 let a = execute('lcs find e ^\#includ.') |
88 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a) | 88 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a) |
89 call assert_equal('#include <assert.h>', getline('.')) | 89 call assert_equal('#include <assert.h>', getline('.')) |
90 lnext | 90 lnext |
91 call assert_equal('#include "main.c"', getline('.')) | 91 call assert_equal('#include "main.c"', getline('.')) |
92 lnext | 92 lnext |
94 call assert_fails('lnext', 'E553:') | 94 call assert_fails('lnext', 'E553:') |
95 | 95 |
96 " Test 8: Find this file | 96 " Test 8: Find this file |
97 for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c'] | 97 for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c'] |
98 enew | 98 enew |
99 let a=execute(cmd) | 99 let a = execute(cmd) |
100 call assert_true(a =~ '"Xmemfile_test.c" \d\+L, \d\+C') | 100 call assert_true(a =~ '"Xmemfile_test.c" \d\+L, \d\+C') |
101 call assert_equal('Xmemfile_test.c', @%) | 101 call assert_equal('Xmemfile_test.c', @%) |
102 endfor | 102 endfor |
103 | 103 |
104 " Test 9: Find files #including this file | 104 " Test 9: Find files #including this file |
105 for cmd in ['cs find i assert.h', 'cs find 8 assert.h'] | 105 for cmd in ['cs find i assert.h', 'cs find 8 assert.h'] |
106 enew | 106 enew |
107 let a=execute(cmd) | 107 let a = execute(cmd) |
108 let alines = split(a, '\n', 1) | 108 let alines = split(a, '\n', 1) |
109 call assert_equal('', alines[0]) | 109 call assert_equal('', alines[0]) |
110 call assert_true(alines[1] =~ '"Xmemfile_test.c" \d\+L, \d\+C') | 110 call assert_true(alines[1] =~ '"Xmemfile_test.c" \d\+L, \d\+C') |
111 call assert_equal('(1 of 1): <<global>> #include <assert.h>', alines[2]) | 111 call assert_equal('(1 of 1): <<global>> #include <assert.h>', alines[2]) |
112 call assert_equal('#include <assert.h>', getline('.')) | 112 call assert_equal('#include <assert.h>', getline('.')) |
116 call assert_fails('cs find x', 'E560:') | 116 call assert_fails('cs find x', 'E560:') |
117 | 117 |
118 " Test 11: Find places where this symbol is assigned a value | 118 " Test 11: Find places where this symbol is assigned a value |
119 " this needs a cscope >= 15.8 | 119 " this needs a cscope >= 15.8 |
120 " unfortunately, Travis has cscope version 15.7 | 120 " unfortunately, Travis has cscope version 15.7 |
121 let cscope_version=systemlist('cscope --version')[0] | 121 let cscope_version = systemlist('cscope --version')[0] |
122 let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) | 122 let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) |
123 if cs_version >= 15.8 | 123 if cs_version >= 15.8 |
124 for cmd in ['cs find a item', 'cs find 9 item'] | 124 for cmd in ['cs find a item', 'cs find 9 item'] |
125 let a=execute(cmd) | 125 let a = execute(cmd) |
126 call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1)) | 126 call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1)) |
127 call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.')) | 127 call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.')) |
128 cnext | 128 cnext |
129 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) | 129 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) |
130 cnext | 130 cnext |
133 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) | 133 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) |
134 endfor | 134 endfor |
135 endif | 135 endif |
136 | 136 |
137 " Test 12: leading whitespace is not removed for cscope find text | 137 " Test 12: leading whitespace is not removed for cscope find text |
138 let a=execute('cscope find t test_mf_hash') | 138 let a = execute('cscope find t test_mf_hash') |
139 call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1)) | 139 call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1)) |
140 call assert_equal(' test_mf_hash();', getline('.')) | 140 call assert_equal(' test_mf_hash();', getline('.')) |
141 | 141 |
142 " Test 13: test with scscope | 142 " Test 13: test with scscope |
143 let a=execute('scs find t Bram') | 143 let a = execute('scs find t Bram') |
144 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) | 144 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) |
145 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) | 145 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) |
146 | 146 |
147 " Test 14: cscope help | 147 " Test 14: cscope help |
148 for cmd in ['cs', 'cs help', 'cs xxx'] | 148 for cmd in ['cs', 'cs help', 'cs xxx'] |
149 let a=execute(cmd) | 149 let a = execute(cmd) |
150 call assert_match('^cscope commands:\n', a) | 150 call assert_match('^cscope commands:\n', a) |
151 call assert_match('\nadd :', a) | 151 call assert_match('\nadd :', a) |
152 call assert_match('\nfind :', a) | 152 call assert_match('\nfind :', a) |
153 call assert_match('\nhelp : Show this message', a) | 153 call assert_match('\nhelp : Show this message', a) |
154 call assert_match('\nkill : Kill a connection', a) | 154 call assert_match('\nkill : Kill a connection', a) |
155 call assert_match('\nreset: Reinit all connections', a) | 155 call assert_match('\nreset: Reinit all connections', a) |
156 call assert_match('\nshow : Show connections', a) | 156 call assert_match('\nshow : Show connections', a) |
157 endfor | 157 endfor |
158 let a=execute('scscope help') | 158 let a = execute('scscope help') |
159 call assert_match('This cscope command does not support splitting the window\.', a) | 159 call assert_match('This cscope command does not support splitting the window\.', a) |
160 | 160 |
161 " Test 15: reset connections | 161 " Test 15: reset connections |
162 let a=execute('cscope reset') | 162 let a = execute('cscope reset') |
163 call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a) | 163 call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a) |
164 call assert_match('\nAll cscope databases reset', a) | 164 call assert_match('\nAll cscope databases reset', a) |
165 | 165 |
166 " Test 16: cscope show | 166 " Test 16: cscope show |
167 let a=execute('cscope show') | 167 let a = execute('cscope show') |
168 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a) | 168 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a) |
169 | 169 |
170 " Test 17: cstag and 'csto' option | 170 " Test 17: cstag and 'csto' option |
171 set csto=0 | 171 set csto=0 |
172 let a=execute('cstag TEST_COUNT') | 172 let a = execute('cstag TEST_COUNT') |
173 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a) | 173 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a) |
174 call assert_equal('#define TEST_COUNT 50000', getline('.')) | 174 call assert_equal('#define TEST_COUNT 50000', getline('.')) |
175 set csto=1 | 175 set csto=1 |
176 let a=execute('cstag index_to_key') | 176 let a = execute('cstag index_to_key') |
177 call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a) | 177 call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a) |
178 call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.')) | 178 call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.')) |
179 call assert_fails('cstag xxx', 'E257:') | 179 call assert_fails('cstag xxx', 'E257:') |
180 call assert_fails('cstag', 'E562:') | 180 call assert_fails('cstag', 'E562:') |
181 | 181 |
182 " Test 18: 'cst' option | 182 " Test 18: 'cst' option |
183 set nocst | 183 set nocst |
184 call assert_fails('tag TEST_COUNT', 'E426:') | 184 call assert_fails('tag TEST_COUNT', 'E426:') |
185 set cst | 185 set cst |
186 let a=execute('tag TEST_COUNT') | 186 let a = execute('tag TEST_COUNT') |
187 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a) | 187 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a) |
188 call assert_equal('#define TEST_COUNT 50000', getline('.')) | 188 call assert_equal('#define TEST_COUNT 50000', getline('.')) |
189 let a=execute('tags') | 189 let a = execute('tags') |
190 call assert_match('1 1 TEST_COUNT\s\+\d\+\s\+#define index_to_key', a) | 190 call assert_match('1 1 TEST_COUNT\s\+\d\+\s\+#define index_to_key', a) |
191 | 191 |
192 " Test 19: this should trigger call to cs_print_tags() | 192 " Test 19: this should trigger call to cs_print_tags() |
193 " Unclear how to check result though, we just exercise the code. | 193 " Unclear how to check result though, we just exercise the code. |
194 set cst cscopequickfix=s0 | 194 set cst cscopequickfix=s0 |
196 | 196 |
197 " Test 20: cscope kill | 197 " Test 20: cscope kill |
198 call assert_fails('cscope kill 2', 'E261:') | 198 call assert_fails('cscope kill 2', 'E261:') |
199 call assert_fails('cscope kill xxx', 'E261:') | 199 call assert_fails('cscope kill xxx', 'E261:') |
200 | 200 |
201 let a=execute('cscope kill 0') | 201 let a = execute('cscope kill 0') |
202 call assert_match('cscope connection 0 closed', a) | 202 call assert_match('cscope connection 0 closed', a) |
203 | 203 |
204 cscope add Xcscope.out | 204 cscope add Xcscope.out |
205 let a=execute('cscope kill Xcscope.out') | 205 let a = execute('cscope kill Xcscope.out') |
206 call assert_match('cscope connection Xcscope.out closed', a) | 206 call assert_match('cscope connection Xcscope.out closed', a) |
207 | 207 |
208 cscope add Xcscope.out . | 208 cscope add Xcscope.out . |
209 let a=execute('cscope kill -1') | 209 let a = execute('cscope kill -1') |
210 call assert_match('cscope connection .*Xcscope.out closed', a) | 210 call assert_match('cscope connection .*Xcscope.out closed', a) |
211 let a=execute('cscope kill -1') | 211 let a = execute('cscope kill -1') |
212 call assert_equal('', a) | 212 call assert_equal('', a) |
213 | 213 |
214 " Test 21: 'csprg' option | 214 " Test 21: 'csprg' option |
215 call assert_equal('cscope', &csprg) | 215 call assert_equal('cscope', &csprg) |
216 set csprg=doesnotexist | 216 set csprg=doesnotexist |
218 set csprg=cscope | 218 set csprg=cscope |
219 | 219 |
220 " Test 22: multiple cscope connections | 220 " Test 22: multiple cscope connections |
221 cscope add Xcscope.out | 221 cscope add Xcscope.out |
222 cscope add Xcscope2.out . -C | 222 cscope add Xcscope2.out . -C |
223 let a=execute('cscope show') | 223 let a = execute('cscope show') |
224 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a) | 224 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a) |
225 call assert_match('\n 1 \d\+.*Xcscope2.out\s*\.', a) | 225 call assert_match('\n 1 \d\+.*Xcscope2.out\s*\.', a) |
226 | 226 |
227 " Test 23: test Ex command line completion | 227 " Test 23: test Ex command line completion |
228 call feedkeys(":cs \<C-A>\<C-B>\"\<CR>", 'tx') | 228 call feedkeys(":cs \<C-A>\<C-B>\"\<CR>", 'tx') |
269 | 269 |
270 func Test_withoutCscopeConnection() | 270 func Test_withoutCscopeConnection() |
271 call assert_equal(cscope_connection(), 0) | 271 call assert_equal(cscope_connection(), 0) |
272 | 272 |
273 call assert_fails('cscope find s main', 'E567:') | 273 call assert_fails('cscope find s main', 'E567:') |
274 let a=execute('cscope show') | 274 let a = execute('cscope show') |
275 call assert_match('no cscope connections', a) | 275 call assert_match('no cscope connections', a) |
276 endfunc | 276 endfunc |
277 | 277 |
278 | 278 |
279 " vim: shiftwidth=2 sts=2 expandtab | 279 " vim: shiftwidth=2 sts=2 expandtab |