comparison src/testdir/test_goto.vim @ 17172:6990c1160ea5 v8.1.1585

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