Mercurial > vim
comparison src/testdir/test_goto.vim @ 16720:9c90cf08cfa8 v8.1.1362
patch 8.1.1362: code and data in tests can be hard to read
commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 20 22:12:34 2019 +0200
patch 8.1.1362: code and data in tests can be hard to read
Problem: Code and data in tests can be hard to read.
Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 20 May 2019 22:15:06 +0200 |
parents | a04738ab7670 |
children | 6990c1160ea5 |
comparison
equal
deleted
inserted
replaced
16719:27f2a2799604 | 16720:9c90cf08cfa8 |
---|---|
13 call assert_equal(a:col, col('.')) | 13 call assert_equal(a:col, col('.')) |
14 quit! | 14 quit! |
15 endfunc | 15 endfunc |
16 | 16 |
17 func Test_gD() | 17 func Test_gD() |
18 let lines = [ | 18 let lines =<< trim [CODE] |
19 \ 'int x;', | 19 int x; |
20 \ '', | 20 |
21 \ 'int func(void)', | 21 int func(void) |
22 \ '{', | 22 { |
23 \ ' return x;', | 23 return x; |
24 \ '}', | 24 } |
25 \ ] | 25 [CODE] |
26 | |
26 call XTest_goto_decl('gD', lines, 1, 5) | 27 call XTest_goto_decl('gD', lines, 1, 5) |
27 endfunc | 28 endfunc |
28 | 29 |
29 func Test_gD_too() | 30 func Test_gD_too() |
30 let lines = [ | 31 let lines =<< trim [CODE] |
31 \ 'Filename x;', | 32 Filename x; |
32 \ '', | 33 |
33 \ 'int Filename', | 34 int Filename |
34 \ 'int func() {', | 35 int func() { |
35 \ ' Filename x;', | 36 Filename x; |
36 \ ' return x;', | 37 return x; |
37 \ ] | 38 [CODE] |
39 | |
38 call XTest_goto_decl('gD', lines, 1, 10) | 40 call XTest_goto_decl('gD', lines, 1, 10) |
39 endfunc | 41 endfunc |
40 | 42 |
41 func Test_gD_comment() | 43 func Test_gD_comment() |
42 let lines = [ | 44 let lines =<< trim [CODE] |
43 \ '/* int x; */', | 45 /* int x; */ |
44 \ 'int x;', | 46 int x; |
45 \ '', | 47 |
46 \ 'int func(void)', | 48 int func(void) |
47 \ '{', | 49 { |
48 \ ' return x;', | 50 return x; |
49 \ '}', | 51 } |
50 \ ] | 52 [CODE] |
53 | |
51 call XTest_goto_decl('gD', lines, 2, 5) | 54 call XTest_goto_decl('gD', lines, 2, 5) |
52 endfunc | 55 endfunc |
53 | 56 |
54 func Test_gD_inline_comment() | 57 func Test_gD_inline_comment() |
55 let lines = [ | 58 let lines =<< trim [CODE] |
56 \ 'int y /* , x */;', | 59 int y /* , x */; |
57 \ 'int x;', | 60 int x; |
58 \ '', | 61 |
59 \ 'int func(void)', | 62 int func(void) |
60 \ '{', | 63 { |
61 \ ' return x;', | 64 return x; |
62 \ '}', | 65 } |
63 \ ] | 66 [CODE] |
67 | |
64 call XTest_goto_decl('gD', lines, 2, 5) | 68 call XTest_goto_decl('gD', lines, 2, 5) |
65 endfunc | 69 endfunc |
66 | 70 |
67 func Test_gD_string() | 71 func Test_gD_string() |
68 let lines = [ | 72 let lines =<< trim [CODE] |
69 \ 'char *s[] = "x";', | 73 char *s[] = "x"; |
70 \ 'int x = 1;', | 74 int x = 1; |
71 \ '', | 75 |
72 \ 'int func(void)', | 76 int func(void) |
73 \ '{', | 77 { |
74 \ ' return x;', | 78 return x; |
75 \ '}', | 79 } |
76 \ ] | 80 [CODE] |
81 | |
77 call XTest_goto_decl('gD', lines, 2, 5) | 82 call XTest_goto_decl('gD', lines, 2, 5) |
78 endfunc | 83 endfunc |
79 | 84 |
80 func Test_gD_string_same_line() | 85 func Test_gD_string_same_line() |
81 let lines = [ | 86 let lines =<< trim [CODE] |
82 \ 'char *s[] = "x", int x = 1;', | 87 char *s[] = "x", int x = 1; |
83 \ '', | 88 |
84 \ 'int func(void)', | 89 int func(void) |
85 \ '{', | 90 { |
86 \ ' return x;', | 91 return x; |
87 \ '}', | 92 } |
88 \ ] | 93 [CODE] |
94 | |
89 call XTest_goto_decl('gD', lines, 1, 22) | 95 call XTest_goto_decl('gD', lines, 1, 22) |
90 endfunc | 96 endfunc |
91 | 97 |
92 func Test_gD_char() | 98 func Test_gD_char() |
93 let lines = [ | 99 let lines =<< trim [CODE] |
94 \ "char c = 'x';", | 100 char c = 'x'; |
95 \ 'int x = 1;', | 101 int x = 1; |
96 \ '', | 102 |
97 \ 'int func(void)', | 103 int func(void) |
98 \ '{', | 104 { |
99 \ ' return x;', | 105 return x; |
100 \ '}', | 106 } |
101 \ ] | 107 [CODE] |
108 | |
102 call XTest_goto_decl('gD', lines, 2, 5) | 109 call XTest_goto_decl('gD', lines, 2, 5) |
103 endfunc | 110 endfunc |
104 | 111 |
105 func Test_gd() | 112 func Test_gd() |
106 let lines = [ | 113 let lines =<< trim [CODE] |
107 \ 'int x;', | 114 int x; |
108 \ '', | 115 |
109 \ 'int func(int x)', | 116 int func(int x) |
110 \ '{', | 117 { |
111 \ ' return x;', | 118 return x; |
112 \ '}', | 119 } |
113 \ ] | 120 [CODE] |
121 | |
114 call XTest_goto_decl('gd', lines, 3, 14) | 122 call XTest_goto_decl('gd', lines, 3, 14) |
115 endfunc | 123 endfunc |
116 | 124 |
117 func Test_gd_not_local() | 125 func Test_gd_not_local() |
118 let lines = [ | 126 let lines =<< trim [CODE] |
119 \ 'int func1(void)', | 127 int func1(void) |
120 \ '{', | 128 { |
121 \ ' return x;', | 129 return x; |
122 \ '}', | 130 } |
123 \ '', | 131 |
124 \ 'int func2(int x)', | 132 int func2(int x) |
125 \ '{', | 133 { |
126 \ ' return x;', | 134 return x; |
127 \ '}', | 135 } |
128 \ ] | 136 [CODE] |
137 | |
129 call XTest_goto_decl('gd', lines, 3, 10) | 138 call XTest_goto_decl('gd', lines, 3, 10) |
130 endfunc | 139 endfunc |
131 | 140 |
132 func Test_gd_kr_style() | 141 func Test_gd_kr_style() |
133 let lines = [ | 142 let lines =<< trim [CODE] |
134 \ 'int func(x)', | 143 int func(x) |
135 \ ' int x;', | 144 int x; |
136 \ '{', | 145 { |
137 \ ' return x;', | 146 return x; |
138 \ '}', | 147 } |
139 \ ] | 148 [CODE] |
149 | |
140 call XTest_goto_decl('gd', lines, 2, 7) | 150 call XTest_goto_decl('gd', lines, 2, 7) |
141 endfunc | 151 endfunc |
142 | 152 |
143 func Test_gd_missing_braces() | 153 func Test_gd_missing_braces() |
144 let lines = [ | 154 let lines =<< trim [CODE] |
145 \ 'def func1(a)', | 155 def func1(a) |
146 \ ' a + 1', | 156 a + 1 |
147 \ 'end', | 157 end |
148 \ '', | 158 |
149 \ 'a = 1', | 159 a = 1 |
150 \ '', | 160 |
151 \ 'def func2()', | 161 def func2() |
152 \ ' return a', | 162 return a |
153 \ 'end', | 163 end |
154 \ ] | 164 [CODE] |
165 | |
155 call XTest_goto_decl('gd', lines, 1, 11) | 166 call XTest_goto_decl('gd', lines, 1, 11) |
156 endfunc | 167 endfunc |
157 | 168 |
158 func Test_gd_comment() | 169 func Test_gd_comment() |
159 let lines = [ | 170 let lines =<< trim [CODE] |
160 \ 'int func(void)', | 171 int func(void) |
161 \ '{', | 172 { |
162 \ ' /* int x; */', | 173 /* int x; */ |
163 \ ' int x;', | 174 int x; |
164 \ ' return x;', | 175 return x; |
165 \ '}', | 176 } |
166 \] | 177 [CODE] |
178 | |
167 call XTest_goto_decl('gd', lines, 4, 7) | 179 call XTest_goto_decl('gd', lines, 4, 7) |
168 endfunc | 180 endfunc |
169 | 181 |
170 func Test_gd_comment_in_string() | 182 func Test_gd_comment_in_string() |
171 let lines = [ | 183 let lines =<< trim [CODE] |
172 \ 'int func(void)', | 184 int func(void) |
173 \ '{', | 185 { |
174 \ ' char *s ="//"; int x;', | 186 char *s ="//"; int x; |
175 \ ' int x;', | 187 int x; |
176 \ ' return x;', | 188 return x; |
177 \ '}', | 189 } |
178 \] | 190 [CODE] |
191 | |
179 call XTest_goto_decl('gd', lines, 3, 22) | 192 call XTest_goto_decl('gd', lines, 3, 22) |
180 endfunc | 193 endfunc |
181 | 194 |
182 func Test_gd_string_in_comment() | 195 func Test_gd_string_in_comment() |
183 set comments= | 196 set comments= |
184 let lines = [ | 197 let lines =<< trim [CODE] |
185 \ 'int func(void)', | 198 int func(void) |
186 \ '{', | 199 { |
187 \ ' /* " */ int x;', | 200 /* " */ int x; |
188 \ ' int x;', | 201 int x; |
189 \ ' return x;', | 202 return x; |
190 \ '}', | 203 } |
191 \] | 204 [CODE] |
205 | |
192 call XTest_goto_decl('gd', lines, 3, 15) | 206 call XTest_goto_decl('gd', lines, 3, 15) |
193 set comments& | 207 set comments& |
194 endfunc | 208 endfunc |
195 | 209 |
196 func Test_gd_inline_comment() | 210 func Test_gd_inline_comment() |
197 let lines = [ | 211 let lines =<< trim [CODE] |
198 \ 'int func(/* x is an int */ int x)', | 212 int func(/* x is an int */ int x) |
199 \ '{', | 213 { |
200 \ ' return x;', | 214 return x; |
201 \ '}', | 215 } |
202 \ ] | 216 [CODE] |
217 | |
203 call XTest_goto_decl('gd', lines, 1, 32) | 218 call XTest_goto_decl('gd', lines, 1, 32) |
204 endfunc | 219 endfunc |
205 | 220 |
206 func Test_gd_inline_comment_only() | 221 func Test_gd_inline_comment_only() |
207 let lines = [ | 222 let lines =<< trim [CODE] |
208 \ 'int func(void) /* one lonely x */', | 223 int func(void) /* one lonely x */ |
209 \ '{', | 224 { |
210 \ ' return x;', | 225 return x; |
211 \ '}', | 226 } |
212 \ ] | 227 [CODE] |
228 | |
213 call XTest_goto_decl('gd', lines, 3, 10) | 229 call XTest_goto_decl('gd', lines, 3, 10) |
214 endfunc | 230 endfunc |
215 | 231 |
216 func Test_gd_inline_comment_body() | 232 func Test_gd_inline_comment_body() |
217 let lines = [ | 233 let lines =<< trim [CODE] |
218 \ 'int func(void)', | 234 int func(void) |
219 \ '{', | 235 { |
220 \ ' int y /* , x */;', | 236 int y /* , x */; |
221 \ '', | 237 |
222 \ ' for (/* int x = 0 */; y < 2; y++);', | 238 for (/* int x = 0 */; y < 2; y++); |
223 \ '', | 239 |
224 \ ' int x = 0;', | 240 int x = 0; |
225 \ '', | 241 |
226 \ ' return x;', | 242 return x; |
227 \ '}', | 243 } |
228 \ ] | 244 [CODE] |
245 | |
229 call XTest_goto_decl('gd', lines, 7, 7) | 246 call XTest_goto_decl('gd', lines, 7, 7) |
230 endfunc | 247 endfunc |
231 | 248 |
232 func Test_gd_trailing_multiline_comment() | 249 func Test_gd_trailing_multiline_comment() |
233 let lines = [ | 250 let lines =<< trim [CODE] |
234 \ 'int func(int x) /* x is an int */', | 251 int func(int x) /* x is an int */ |
235 \ '{', | 252 { |
236 \ ' return x;', | 253 return x; |
237 \ '}', | 254 } |
238 \ ] | 255 [CODE] |
256 | |
239 call XTest_goto_decl('gd', lines, 1, 14) | 257 call XTest_goto_decl('gd', lines, 1, 14) |
240 endfunc | 258 endfunc |
241 | 259 |
242 func Test_gd_trailing_comment() | 260 func Test_gd_trailing_comment() |
243 let lines = [ | 261 let lines =<< trim [CODE] |
244 \ 'int func(int x) // x is an int', | 262 int func(int x) // x is an int |
245 \ '{', | 263 { |
246 \ ' return x;', | 264 return x; |
247 \ '}', | 265 } |
248 \ ] | 266 [CODE] |
267 | |
249 call XTest_goto_decl('gd', lines, 1, 14) | 268 call XTest_goto_decl('gd', lines, 1, 14) |
250 endfunc | 269 endfunc |
251 | 270 |
252 func Test_gd_string() | 271 func Test_gd_string() |
253 let lines = [ | 272 let lines =<< trim [CODE] |
254 \ 'int func(void)', | 273 int func(void) |
255 \ '{', | 274 { |
256 \ ' char *s = "x";', | 275 char *s = "x"; |
257 \ ' int x = 1;', | 276 int x = 1; |
258 \ '', | 277 |
259 \ ' return x;', | 278 return x; |
260 \ '}', | 279 } |
261 \ ] | 280 [CODE] |
262 call XTest_goto_decl('gd', lines, 4, 7) | 281 call XTest_goto_decl('gd', lines, 4, 7) |
263 endfunc | 282 endfunc |
264 | 283 |
265 func Test_gd_string_only() | 284 func Test_gd_string_only() |
266 let lines = [ | 285 let lines =<< trim [CODE] |
267 \ 'int func(void)', | 286 int func(void) |
268 \ '{', | 287 { |
269 \ ' char *s = "x";', | 288 char *s = "x"; |
270 \ '', | 289 |
271 \ ' return x;', | 290 return x; |
272 \ '}', | 291 } |
273 \ ] | 292 [CODE] |
293 | |
274 call XTest_goto_decl('gd', lines, 5, 10) | 294 call XTest_goto_decl('gd', lines, 5, 10) |
275 endfunc | 295 endfunc |
276 | 296 |
277 " Check that setting 'cursorline' does not change curswant | 297 " Check that setting 'cursorline' does not change curswant |
278 func Test_cursorline_keep_col() | 298 func Test_cursorline_keep_col() |
287 bwipe! | 307 bwipe! |
288 set nocursorline | 308 set nocursorline |
289 endfunc | 309 endfunc |
290 | 310 |
291 func Test_gd_local_block() | 311 func Test_gd_local_block() |
292 let lines = [ | 312 let lines =<< trim [CODE] |
293 \ ' int main()', | 313 int main() |
294 \ '{', | 314 { |
295 \ ' char *a = "NOT NULL";', | 315 char *a = "NOT NULL"; |
296 \ ' if(a)', | 316 if(a) |
297 \ ' {', | 317 { |
298 \ ' char *b = a;', | 318 char *b = a; |
299 \ ' printf("%s\n", b);', | 319 printf("%s\n", b); |
300 \ ' }', | 320 } |
301 \ ' else', | 321 else |
302 \ ' {', | 322 { |
303 \ ' char *b = "NULL";', | 323 char *b = "NULL"; |
304 \ ' return b;', | 324 return b; |
305 \ ' }', | 325 } |
306 \ '', | 326 |
307 \ ' return 0;', | 327 return 0; |
308 \ '}', | 328 } |
309 \ ] | 329 [CODE] |
330 | |
310 call XTest_goto_decl('1gd', lines, 11, 11) | 331 call XTest_goto_decl('1gd', lines, 11, 11) |
311 endfunc | 332 endfunc |
312 | 333 |
313 func Test_motion_if_elif_else_endif() | 334 func Test_motion_if_elif_else_endif() |
314 new | 335 new |