Mercurial > vim
annotate src/testdir/test3.in @ 9649:fd9727ae3c49 v7.4.2101
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 24 22:04:11 2016 +0200
patch 7.4.2101
Problem: Looping over windows, buffers and tab pages is inconsistant.
Solution: Use FOR_ALL_ macros everywhere. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Jul 2016 22:15:07 +0200 |
parents | c6a7305972fe |
children | 0bbbe99c8432 |
rev | line source |
---|---|
7 | 1 /* vim: set cin ts=4 sw=4 : */ |
2 | |
3 Test for 'cindent' | |
4 | |
5 STARTTEST | |
6 :so small.vim | |
1624 | 7 :set nocompatible viminfo+=nviminfo modeline |
7 | 8 :edit " read modeline |
9 /start of AUTO | |
10 =/end of AUTO | |
11 ENDTEST | |
12 | |
829 | 13 /* start of AUTO matically checked vim: set ts=4 : */ |
7 | 14 { |
15 if (test) | |
16 cmd1; | |
17 cmd2; | |
18 } | |
19 | |
20 { | |
21 if (test) | |
22 cmd1; | |
23 else | |
24 cmd2; | |
25 } | |
26 | |
27 { | |
28 if (test) | |
29 { | |
30 cmd1; | |
31 cmd2; | |
32 } | |
33 } | |
34 | |
35 { | |
36 if (test) | |
37 { | |
38 cmd1; | |
39 else | |
40 } | |
41 } | |
42 | |
43 { | |
44 while (this) | |
45 if (test) | |
46 cmd1; | |
47 cmd2; | |
48 } | |
49 | |
50 { | |
51 while (this) | |
52 if (test) | |
53 cmd1; | |
54 else | |
55 cmd2; | |
56 } | |
57 | |
58 { | |
59 if (test) | |
60 { | |
61 cmd; | |
62 } | |
63 | |
64 if (test) | |
65 cmd; | |
66 } | |
67 | |
68 { | |
69 if (test) { | |
70 cmd; | |
71 } | |
72 | |
73 if (test) cmd; | |
74 } | |
75 | |
76 { | |
77 cmd1; | |
78 for (blah) | |
79 while (this) | |
80 if (test) | |
81 cmd2; | |
82 cmd3; | |
83 } | |
84 | |
85 { | |
86 cmd1; | |
87 for (blah) | |
88 while (this) | |
89 if (test) | |
90 cmd2; | |
91 cmd3; | |
92 | |
93 if (test) | |
94 { | |
95 cmd1; | |
96 cmd2; | |
97 cmd3; | |
98 } | |
99 } | |
100 | |
101 | |
102 /* Test for 'cindent' do/while mixed with if/else: */ | |
103 | |
104 { | |
105 do | |
106 if (asdf) | |
107 asdfasd; | |
108 while (cond); | |
109 | |
110 do | |
111 if (asdf) | |
112 while (asdf) | |
113 asdf; | |
114 while (asdf); | |
115 } | |
116 | |
117 /* Test for 'cindent' with two ) on a continuation line */ | |
118 { | |
119 if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d | |
120 aal;sdkjf ( ;asldfkja;sldfk | |
121 al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) | |
122 line up here; | |
123 } | |
124 | |
125 | |
126 /* C++ tests: */ | |
127 | |
128 // foo() these three lines should remain in column 0 | |
129 // { | |
130 // } | |
131 | |
132 /* Test for continuation and unterminated lines: */ | |
133 { | |
134 i = 99 + 14325 + | |
135 21345 + | |
136 21345 + | |
137 21345 + ( 21345 + | |
138 21345) + | |
139 2345 + | |
140 1234; | |
141 c = 1; | |
142 } | |
143 | |
144 /* | |
145 testje for indent with empty line | |
146 | |
147 here */ | |
148 | |
149 { | |
150 if (testing && | |
151 not a joke || | |
152 line up here) | |
153 hay; | |
154 if (testing && | |
155 (not a joke || testing | |
156 )line up here) | |
157 hay; | |
158 if (testing && | |
159 (not a joke || testing | |
160 line up here)) | |
161 hay; | |
162 } | |
163 | |
164 | |
165 { | |
166 switch (c) | |
167 { | |
168 case xx: | |
169 do | |
170 if (asdf) | |
171 do | |
172 asdfasdf; | |
173 while (asdf); | |
174 else | |
175 asdfasdf; | |
176 while (cond); | |
177 case yy: | |
178 case xx: | |
179 case zz: | |
180 testing; | |
181 } | |
182 } | |
183 | |
184 { | |
185 if (cond) { | |
186 foo; | |
187 } | |
188 else | |
189 { | |
190 bar; | |
191 } | |
192 } | |
193 | |
194 { | |
195 if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf | |
196 alsdkfj (asldk;fj | |
197 awith cino=(0 ;lf this one goes to below the paren with == | |
198 ;laksjfd ;lsakdjf ;alskdf asd) | |
199 asdfasdf;))) | |
200 asdfasdf; | |
201 } | |
202 | |
203 int | |
204 func(a, b) | |
205 int a; | |
206 int c; | |
207 { | |
208 if (c1 && (c2 || | |
209 c3)) | |
210 foo; | |
211 if (c1 && | |
212 (c2 || c3) | |
213 ) | |
214 } | |
215 | |
216 { | |
217 while (asd) | |
218 { | |
219 if (asdf) | |
220 if (test) | |
221 if (that) | |
222 { | |
223 if (asdf) | |
224 do | |
225 cdasd; | |
226 while (as | |
227 df); | |
228 } | |
229 else | |
230 if (asdf) | |
231 asdf; | |
232 else | |
233 asdf; | |
234 asdf; | |
235 } | |
236 } | |
237 | |
238 { | |
239 s = "/*"; b = ';' | |
240 s = "/*"; b = ';'; | |
241 a = b; | |
242 } | |
243 | |
244 { | |
245 switch (a) | |
246 { | |
247 case a: | |
248 switch (t) | |
249 { | |
250 case 1: | |
251 cmd; | |
252 break; | |
253 case 2: | |
254 cmd; | |
255 break; | |
256 } | |
257 cmd; | |
258 break; | |
259 case b: | |
260 { | |
261 int i; | |
262 cmd; | |
263 } | |
264 break; | |
265 case c: { | |
266 int i; | |
267 cmd; | |
268 } | |
269 case d: if (cond && | |
270 test) { /* this line doesn't work right */ | |
271 int i; | |
272 cmd; | |
273 } | |
274 break; | |
275 } | |
276 } | |
277 | |
278 { | |
279 if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && | |
280 (bp_to->b_p_initialized || | |
281 (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
282 return; | |
283 label : | |
284 asdf = asdf ? | |
285 asdf : asdf; | |
286 asdf = asdf ? | |
287 asdf: asdf; | |
288 } | |
289 | |
290 /* Special Comments : This function has the added complexity (compared */ | |
291 /* : to addtolist) of having to check for a detail */ | |
292 /* : texture and add that to the list first. */ | |
293 | |
294 char *(array[100]) = { | |
295 "testje", | |
296 "foo", | |
297 "bar", | |
298 } | |
299 | |
300 enum soppie | |
301 { | |
3218 | 302 yes = 0, |
303 no, | |
304 maybe | |
7 | 305 }; |
306 | |
307 typedef enum soppie | |
308 { | |
3218 | 309 yes = 0, |
310 no, | |
311 maybe | |
7 | 312 }; |
313 | |
3218 | 314 static enum |
315 { | |
316 yes = 0, | |
317 no, | |
318 maybe | |
319 } soppie; | |
320 | |
4187 | 321 public static enum |
322 { | |
323 yes = 0, | |
324 no, | |
325 maybe | |
326 } soppie; | |
327 | |
328 static private enum | |
329 { | |
330 yes = 0, | |
331 no, | |
332 maybe | |
333 } soppie; | |
334 | |
7 | 335 { |
336 int a, | |
337 b; | |
338 } | |
339 | |
340 { | |
341 struct Type | |
342 { | |
343 int i; | |
344 char *str; | |
345 } var[] = | |
346 { | |
347 0, "zero", | |
348 1, "one", | |
349 2, "two", | |
350 3, "three" | |
351 }; | |
352 | |
353 float matrix[3][3] = | |
354 { | |
355 { | |
356 0, | |
357 1, | |
358 2 | |
359 }, | |
360 { | |
361 3, | |
362 4, | |
363 5 | |
364 }, | |
365 { | |
366 6, | |
367 7, | |
368 8 | |
369 } | |
370 }; | |
371 } | |
372 | |
373 { | |
374 /* blah ( blah */ | |
375 /* where does this go? */ | |
376 | |
377 /* blah ( blah */ | |
378 cmd; | |
379 | |
380 func(arg1, | |
381 /* comment */ | |
382 arg2); | |
383 a; | |
384 { | |
385 b; | |
386 { | |
387 c; /* Hey, NOW it indents?! */ | |
388 } | |
389 } | |
390 | |
391 { | |
392 func(arg1, | |
393 arg2, | |
394 arg3); | |
395 /* Hey, what am I doing here? Is this coz of the ","? */ | |
396 } | |
397 } | |
398 | |
399 main () | |
400 { | |
401 if (cond) | |
402 { | |
403 a = b; | |
404 } | |
405 if (cond) { | |
406 a = c; | |
407 } | |
408 if (cond) | |
409 a = d; | |
410 return; | |
411 } | |
412 | |
413 { | |
414 case 2: if (asdf && | |
415 asdfasdf) | |
416 aasdf; | |
417 a = 9; | |
418 case 3: if (asdf) | |
419 aasdf; | |
420 a = 9; | |
421 case 4: x = 1; | |
422 y = 2; | |
423 | |
424 label: if (asdf) | |
425 here; | |
426 | |
427 label: if (asdf && | |
428 asdfasdf) | |
429 { | |
430 } | |
431 | |
432 label: if (asdf && | |
433 asdfasdf) { | |
434 there; | |
435 } | |
436 | |
437 label: if (asdf && | |
438 asdfasdf) | |
439 there; | |
440 } | |
441 | |
442 { | |
443 /* | |
444 hello with ":set comments= cino=c5" | |
445 */ | |
446 | |
447 /* | |
448 hello with ":set comments= cino=" | |
449 */ | |
450 } | |
451 | |
452 | |
453 { | |
454 if (a < b) { | |
455 a = a + 1; | |
456 } else | |
457 a = a + 2; | |
458 | |
459 if (a) | |
460 do { | |
461 testing; | |
462 } while (asdfasdf); | |
463 a = b + 1; | |
464 asdfasdf | |
465 } | |
466 | |
6114 | 467 { |
468 for ( int i = 0; | |
469 i < 10; i++ ) | |
470 { | |
471 } | |
472 i = 0; | |
473 } | |
474 | |
7 | 475 class bob |
476 { | |
477 int foo() {return 1;} | |
478 int bar; | |
479 } | |
480 | |
481 main() | |
482 { | |
483 while(1) | |
484 if (foo) | |
485 { | |
486 bar; | |
487 } | |
488 else { | |
489 asdf; | |
490 } | |
491 misplacedline; | |
492 } | |
493 | |
494 { | |
495 if (clipboard.state == SELECT_DONE | |
496 && ((row == clipboard.start.lnum | |
497 && col >= clipboard.start.col) | |
498 || row > clipboard.start.lnum)) | |
499 } | |
500 | |
501 { | |
502 if (1) {i += 4;} | |
503 where_am_i; | |
504 return 0; | |
505 } | |
506 | |
507 { | |
508 { | |
509 } // sdf(asdf | |
510 if (asdf) | |
511 asd; | |
512 } | |
513 | |
514 { | |
515 label1: | |
516 label2: | |
517 } | |
518 | |
519 { | |
520 int fooRet = foo(pBar1, false /*fKB*/, | |
521 true /*fPTB*/, 3 /*nT*/, false /*fDF*/); | |
522 f() { | |
523 for ( i = 0; | |
524 i < m; | |
525 /* c */ i++ ) { | |
526 a = b; | |
527 } | |
528 } | |
529 } | |
530 | |
531 { | |
532 f1(/*comment*/); | |
533 f2(); | |
534 } | |
535 | |
536 { | |
537 do { | |
538 if (foo) { | |
539 } else | |
540 ; | |
541 } while (foo); | |
542 foo(); // was wrong | |
543 } | |
544 | |
545 int x; // no extra indent because of the ; | |
546 void func() | |
547 { | |
548 } | |
549 | |
550 char *tab[] = {"aaa", | |
551 "};", /* }; */ NULL} | |
552 int indented; | |
553 {} | |
554 | |
555 char *a[] = {"aaa", "bbb", | |
556 "ccc", NULL}; | |
557 // here | |
558 | |
559 char *tab[] = {"aaa", | |
560 "xx", /* xx */}; /* asdf */ | |
561 int not_indented; | |
562 | |
563 { | |
564 do { | |
565 switch (bla) | |
566 { | |
567 case 1: if (foo) | |
568 bar; | |
569 } | |
570 } while (boo); | |
571 wrong; | |
572 } | |
573 | |
574 int foo, | |
575 bar; | |
576 int foo; | |
577 | |
578 #if defined(foo) \ | |
579 && defined(bar) | |
580 char * xx = "asdf\ | |
581 foo\ | |
582 bor"; | |
583 int x; | |
584 | |
585 char *foo = "asdf\ | |
586 asdf\ | |
587 asdf", | |
588 *bar; | |
589 | |
590 void f() | |
591 { | |
592 #if defined(foo) \ | |
593 && defined(bar) | |
594 char *foo = "asdf\ | |
595 asdf\ | |
596 asdf", | |
597 *bar; | |
598 { | |
599 int i; | |
600 char *foo = "asdf\ | |
601 asdf\ | |
602 asdf", | |
603 *bar; | |
604 } | |
605 #endif | |
606 } | |
607 #endif | |
608 | |
609 int y; // comment | |
610 // comment | |
611 | |
612 // comment | |
613 | |
614 { | |
615 Constructor(int a, | |
616 int b ) : BaseClass(a) | |
617 { | |
618 } | |
619 } | |
620 | |
621 void foo() | |
622 { | |
623 char one, | |
624 two; | |
625 struct bla piet, | |
626 jan; | |
627 enum foo kees, | |
628 jannie; | |
629 static unsigned sdf, | |
630 krap; | |
631 unsigned int piet, | |
632 jan; | |
633 int | |
634 kees, | |
635 jan; | |
636 } | |
637 | |
638 { | |
639 t(int f, | |
640 int d); // ) | |
641 d(); | |
642 } | |
643 | |
644 Constructor::Constructor(int a, | |
645 int b | |
646 ) : | |
647 BaseClass(a, | |
648 b, | |
649 c), | |
650 mMember(b), | |
651 { | |
652 } | |
653 | |
654 Constructor::Constructor(int a, | |
655 int b ) : | |
656 BaseClass(a) | |
657 { | |
658 } | |
659 | |
660 Constructor::Constructor(int a, | |
661 int b ) /*x*/ : /*x*/ BaseClass(a), | |
662 member(b) | |
663 { | |
664 } | |
665 | |
7206
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
666 A::A(int a, int b) |
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
667 : aa(a), |
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
668 bb(b), |
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
669 cc(c) |
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
670 { |
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
671 } |
c6a7305972fe
commit https://github.com/vim/vim/commit/e01f4f86cef7bed3cb99b26f9f57d86f6eb5fe1a
Christian Brabandt <cb@256bit.org>
parents:
7164
diff
changeset
|
672 |
7 | 673 class CAbc : |
674 public BaseClass1, | |
675 protected BaseClass2 | |
676 { | |
677 int Test() { return FALSE; } | |
678 int Test1() { return TRUE; } | |
679 | |
680 CAbc(int a, int b ) : | |
681 BaseClass(a) | |
682 { | |
683 switch(xxx) | |
684 { | |
685 case abc: | |
686 asdf(); | |
687 break; | |
688 | |
689 case 999: | |
690 baer(); | |
691 break; | |
692 } | |
693 } | |
694 | |
695 public: // <-- this was incoreectly indented before!! | |
696 void testfall(); | |
697 protected: | |
698 void testfall(); | |
699 }; | |
700 | |
701 class CAbc : public BaseClass1, | |
702 protected BaseClass2 | |
703 { | |
704 }; | |
705 | |
706 static struct | |
707 { | |
708 int a; | |
709 int b; | |
710 } variable[COUNT] = | |
711 { | |
712 { | |
713 123, | |
714 456 | |
715 }, | |
716 { | |
717 123, | |
718 456 | |
719 } | |
720 }; | |
721 | |
722 static struct | |
723 { | |
724 int a; | |
725 int b; | |
726 } variable[COUNT] = | |
727 { | |
728 { 123, 456 }, | |
729 { 123, 456 } | |
730 }; | |
731 | |
732 void asdf() /* ind_maxparen may cause trouble here */ | |
733 { | |
734 if ((0 | |
735 && 1 | |
736 && 1 | |
737 && 1 | |
738 && 1 | |
739 && 1 | |
740 && 1 | |
741 && 1 | |
742 && 1 | |
743 && 1 | |
744 && 1 | |
745 && 1 | |
746 && 1 | |
747 && 1 | |
748 && 1 | |
749 && 1 | |
750 && 1 | |
751 && 1 | |
752 && 1 | |
753 && 1 | |
754 && 1 | |
755 && 1 | |
756 && 1 | |
757 && 1 | |
758 && 1 | |
759 && 1)) break; | |
760 } | |
761 | |
827 | 762 foo() |
763 { | |
764 a = cond ? foo() : asdf | |
765 + asdf; | |
766 | |
767 a = cond ? | |
768 foo() : asdf | |
769 + asdf; | |
770 } | |
771 | |
772 int main(void) | |
773 { | |
774 if (a) | |
775 if (b) | |
776 2; | |
777 else 3; | |
778 next_line_of_code(); | |
779 } | |
780 | |
828 | 781 barry() |
782 { | |
783 Foo::Foo (int one, | |
784 int two) | |
785 : something(4) | |
786 {} | |
787 } | |
788 | |
789 barry() | |
790 { | |
791 Foo::Foo (int one, int two) | |
792 : something(4) | |
793 {} | |
794 } | |
795 | |
796 Constructor::Constructor(int a, | |
797 int b | |
798 ) : | |
799 BaseClass(a, | |
800 b, | |
801 c), | |
802 mMember(b) | |
803 { | |
804 } | |
829 | 805 int main () |
806 { | |
807 if (lala) | |
808 do | |
809 ++(*lolo); | |
810 while (lili | |
811 && lele); | |
812 lulu; | |
813 } | |
828 | 814 |
829 | 815 int main () |
816 { | |
817 switch (c) | |
818 { | |
819 case 'c': if (cond) | |
820 { | |
821 } | |
822 } | |
823 } | |
824 | |
825 main() | |
826 { | |
827 (void) MyFancyFuasdfadsfnction( | |
828 argument); | |
829 } | |
830 | |
831 main() | |
832 { | |
833 char foo[] = "/*"; | |
834 /* as | |
835 df */ | |
836 hello | |
837 } | |
2857 | 838 |
839 /* valid namespaces with normal indent */ | |
840 namespace | |
841 { | |
842 { | |
843 111111111111; | |
844 } | |
845 } | |
846 namespace /* test */ | |
847 { | |
848 11111111111111111; | |
849 } | |
850 namespace // test | |
851 { | |
852 111111111111111111; | |
853 } | |
854 namespace | |
855 { | |
856 111111111111111111; | |
857 } | |
858 namespace test | |
859 { | |
860 111111111111111111; | |
861 } | |
862 namespace{ | |
863 111111111111111111; | |
864 } | |
865 namespace test{ | |
866 111111111111111111; | |
867 } | |
868 namespace { | |
869 111111111111111111; | |
870 } | |
871 namespace test { | |
872 111111111111111111; | |
873 namespace test2 { | |
874 22222222222222222; | |
875 } | |
876 } | |
877 | |
878 /* invalid namespaces use block indent */ | |
879 namespace test test2 { | |
880 111111111111111111111; | |
881 } | |
882 namespace11111111111 { | |
883 111111111111; | |
884 } | |
885 namespace() { | |
886 1111111111111; | |
887 } | |
888 namespace() | |
889 { | |
890 111111111111111111; | |
891 } | |
892 namespace test test2 | |
893 { | |
894 1111111111111111111; | |
895 } | |
896 namespace111111111 | |
897 { | |
898 111111111111111111; | |
899 } | |
900 | |
6971 | 901 void getstring() { |
902 /* Raw strings */ | |
903 const char* s = R"( | |
904 test { | |
905 # comment | |
906 field: 123 | |
907 } | |
908 )"; | |
909 } | |
910 | |
911 void getstring() { | |
912 const char* s = R"foo( | |
913 test { | |
914 # comment | |
915 field: 123 | |
916 } | |
917 )foo"; | |
918 } | |
919 | |
7160
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
920 { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
921 int a[4] = { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
922 [0] = 0, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
923 [1] = 1, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
924 [2] = 2, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
925 [3] = 3, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
926 }; |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
927 } |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
928 |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
929 { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
930 a = b[2] |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
931 + 3; |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
932 } |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
933 |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
934 { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
935 if (1) |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
936 /* aaaaa |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
937 * bbbbb |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
938 */ |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
939 a = 1; |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
940 } |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
941 |
7164
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
942 void func() |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
943 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
944 switch (foo) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
945 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
946 case (bar): |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
947 if (baz()) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
948 quux(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
949 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
950 case (shmoo): |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
951 if (!bar) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
952 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
953 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
954 case (foo1): |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
955 switch (bar) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
956 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
957 case baz: |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
958 baz_f(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
959 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
960 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
961 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
962 default: |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
963 baz(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
964 baz(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
965 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
966 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
967 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
968 |
7 | 969 /* end of AUTO */ |
970 | |
971 STARTTEST | |
972 :set tw=0 wm=60 columns=80 noai fo=croq | |
973 /serious/e | |
974 a about life, the universe, and the rest | |
975 ENDTEST | |
976 | |
977 { | |
978 | |
979 /* this is | |
980 * a real serious important big | |
981 * comment | |
982 */ | |
983 /* insert " about life, the universe, and the rest" after "serious" */ | |
984 } | |
985 | |
986 STARTTEST | |
987 :set nocin | |
988 /comments | |
989 joabout life/happens | |
990 jothere/below | |
991 oline/this | |
992 Ohello | |
993 ENDTEST | |
994 | |
995 { | |
996 /* | |
997 * Testing for comments, without 'cin' set | |
998 */ | |
999 | |
1000 /* | |
1001 * what happens here? | |
1002 */ | |
1003 | |
1004 /* | |
1005 the end of the comment, try inserting a line below */ | |
1006 | |
1007 /* how about | |
1008 this one */ | |
1009 } | |
1010 | |
1011 STARTTEST | |
1012 :set cin | |
1013 /vec2 | |
1014 == | |
1015 ENDTEST | |
1016 | |
1017 { | |
1018 var = this + that + vec[0] * vec[0] | |
1019 + vec[1] * vec[1] | |
1020 + vec2[2] * vec[2]; | |
1021 } | |
1022 | |
1023 STARTTEST | |
1024 :set cin | |
1025 :set cino=}4 | |
1026 /testing1 | |
1027 k2==/testing2 | |
1028 k2== | |
1029 ENDTEST | |
1030 | |
1031 { | |
1032 asdf asdflkajds f; | |
1033 if (tes & ting) { | |
1034 asdf asdf asdf ; | |
1035 asdfa sdf asdf; | |
1036 } | |
1037 testing1; | |
1038 if (tes & ting) | |
1039 { | |
1040 asdf asdf asdf ; | |
1041 asdfa sdf asdf; | |
1042 } | |
1043 testing2; | |
1044 } | |
1045 | |
1046 STARTTEST | |
1047 :set cin | |
1048 :set cino=(0,)20 | |
1049 /main | |
1050 =][ | |
1051 ENDTEST | |
1052 | |
1053 main ( int first_par, /* | |
1054 * Comment for | |
1055 * first par | |
1056 */ | |
1057 int second_par /* | |
1058 * Comment for | |
1059 * second par | |
1060 */ | |
1061 ) | |
1062 { | |
1063 func( first_par, /* | |
1064 * Comment for | |
1065 * first par | |
1066 */ | |
1067 second_par /* | |
1068 * Comment for | |
1069 * second par | |
1070 */ | |
1071 ); | |
1072 | |
1073 } | |
1074 | |
1075 STARTTEST | |
1076 :set cin | |
3578 | 1077 :set cino=es,n0s |
1078 /main | |
1079 =][ | |
1080 ENDTEST | |
1081 | |
1082 main(void) | |
1083 { | |
1084 /* Make sure that cino=X0s is not parsed like cino=Xs. */ | |
1085 if (cond) | |
1086 foo(); | |
1087 else | |
1088 { | |
1089 bar(); | |
1090 } | |
1091 } | |
1092 | |
1093 STARTTEST | |
1094 :set cin | |
7 | 1095 :set cino= |
1096 ]]=][ | |
1097 ENDTEST | |
1098 | |
1099 { | |
1100 do | |
1101 { | |
1102 if () | |
1103 { | |
1104 if () | |
1105 asdf; | |
1106 else | |
1107 asdf; | |
1108 } | |
1109 } while (); | |
1110 cmd; /* this should go under the } */ | |
1111 } | |
1112 | |
1113 STARTTEST | |
1114 ]]=][ | |
1115 ENDTEST | |
1116 | |
1117 void f() | |
1118 { | |
1119 if ( k() ) { | |
1120 l(); | |
1121 | |
1122 } else { /* Start (two words) end */ | |
1123 m(); | |
1124 } | |
1125 | |
1126 n(); | |
1127 } | |
1128 | |
1129 STARTTEST | |
1130 :set cino={s,e-s | |
1131 ]]=][ | |
1132 ENDTEST | |
1133 | |
1134 void f() | |
1135 { | |
1136 if ( k() ) | |
1137 { | |
1138 l(); | |
1139 } else { /* Start (two words) end */ | |
1140 m(); | |
1141 } | |
1142 n(); /* should be under the if () */ | |
1143 } | |
1144 | |
1145 STARTTEST | |
1146 :set cino={s,fs | |
1147 ]]=/ foo | |
1148 ENDTEST | |
1149 | |
1150 void bar(void) | |
1151 { | |
1152 static array[2][2] = | |
1153 { | |
1154 { 1, 2 }, | |
1155 { 3, 4 }, | |
1156 } | |
1157 | |
1158 while (a) | |
1159 { | |
1160 foo(&a); | |
1161 } | |
1162 | |
1163 { | |
1164 int a; | |
1165 { | |
1166 a = a + 1; | |
1167 } | |
1168 } | |
1169 b = a; | |
1170 } | |
1171 | |
1172 void func(void) | |
1173 { | |
1174 a = 1; | |
1175 { | |
1176 b = 2; | |
1177 } | |
1178 c = 3; | |
1179 d = 4; | |
1180 } | |
1181 /* foo */ | |
1182 | |
1183 STARTTEST | |
1184 :set cino= | |
1185 /while | |
1186 ohere | |
1187 ENDTEST | |
1188 | |
1189 a() | |
1190 { | |
1191 do { | |
1192 a = a + | |
1193 a; | |
1194 } while ( a ); /* add text under this line */ | |
1195 if ( a ) | |
1196 a; | |
1197 } | |
1198 | |
1199 STARTTEST | |
1200 :set cino= com= | |
1201 /comment | |
1202 olabel2: b(); label3 /* post */: /* pre */ label4: f(/*com*/); if (/*com*/) cmd(); | |
1203 ENDTEST | |
1204 | |
1205 a() | |
1206 { | |
1207 label1: | |
1208 /* hmm */ | |
1209 // comment | |
1210 } | |
1211 | |
1212 STARTTEST | |
1213 :set comments& comments^=s:/*,m:**,ex:*/ | |
1214 /simple | |
1215 =5j | |
1216 ENDTEST | |
1217 | |
1218 /* | |
1219 * A simple comment | |
1220 */ | |
1221 | |
1222 /* | |
1223 ** A different comment | |
1224 */ | |
1225 | |
1226 STARTTEST | |
1227 :set cino=c0 | |
1228 :set comments& comments-=s1:/* comments^=s0:/* | |
1229 2kdd]]=][ | |
1230 ENDTEST | |
1231 | |
1232 void f() | |
1233 { | |
1234 | |
1235 /********* | |
1236 A comment. | |
1237 *********/ | |
1238 } | |
1239 | |
1240 STARTTEST | |
1241 :set cino=c0,C1 | |
1242 :set comments& comments-=s1:/* comments^=s0:/* | |
1243 2kdd]]=][ | |
1244 ENDTEST | |
1245 | |
1246 void f() | |
1247 { | |
1248 | |
1249 /********* | |
1250 A comment. | |
1251 *********/ | |
1252 } | |
1253 | |
1254 STARTTEST | |
1255 :set cino= | |
1256 ]]=][ | |
1257 ENDTEST | |
1258 | |
1259 void f() | |
1260 { | |
1261 c = c1 && | |
1262 ( | |
1263 c2 || | |
1264 c3 | |
1265 ) && c4; | |
1266 } | |
1267 | |
1268 STARTTEST | |
1269 :set cino=(s | |
1270 2kdd]]=][ | |
1271 ENDTEST | |
1272 | |
1273 void f() | |
1274 { | |
1275 c = c1 && | |
1276 ( | |
1277 c2 || | |
1278 c3 | |
1279 ) && c4; | |
1280 } | |
1281 | |
1282 STARTTEST | |
1283 :set cino=(s,U1 | |
1284 2kdd]]=][ | |
1285 ENDTEST | |
1286 | |
1287 void f() | |
1288 { | |
1289 c = c1 && | |
1290 ( | |
1291 c2 || | |
1292 c3 | |
1293 ) && c4; | |
1294 } | |
1295 | |
1296 STARTTEST | |
1297 :set cino=(0 | |
1298 2kdd]]=][ | |
1299 ENDTEST | |
1300 | |
1301 void f() | |
1302 { | |
1303 if ( c1 | |
1304 && ( c2 | |
1305 || c3)) | |
1306 foo; | |
1307 } | |
1308 | |
1309 STARTTEST | |
1310 :set cino=(0,w1 | |
1311 2kdd]]=][ | |
1312 ENDTEST | |
1313 | |
1314 void f() | |
1315 { | |
1316 if ( c1 | |
1317 && ( c2 | |
1318 || c3)) | |
1319 foo; | |
1320 } | |
1321 | |
1322 STARTTEST | |
1323 :set cino=(s | |
1324 2kdd]]=][ | |
1325 ENDTEST | |
1326 | |
1327 void f() | |
1328 { | |
1329 c = c1 && ( | |
1330 c2 || | |
1331 c3 | |
1332 ) && c4; | |
1333 if ( | |
1334 c1 && c2 | |
1335 ) | |
1336 foo; | |
1337 } | |
1338 | |
1339 STARTTEST | |
1340 :set cino=(s,m1 | |
1341 2kdd]]=][ | |
1342 ENDTEST | |
1343 | |
1344 void f() | |
1345 { | |
1346 c = c1 && ( | |
1347 c2 || | |
1348 c3 | |
1349 ) && c4; | |
1350 if ( | |
1351 c1 && c2 | |
1352 ) | |
1353 foo; | |
1354 } | |
1355 | |
1356 STARTTEST | |
1357 :set cino=b1 | |
1358 2kdd]]=][ | |
1359 ENDTEST | |
1360 | |
1361 void f() | |
1362 { | |
1363 switch (x) | |
1364 { | |
1365 case 1: | |
1366 a = b; | |
1367 break; | |
1368 default: | |
1369 a = 0; | |
1370 break; | |
1371 } | |
1372 } | |
1373 | |
1374 STARTTEST | |
1375 :set cino=(0,W5 | |
1376 2kdd]]=][ | |
1377 ENDTEST | |
1378 | |
1379 void f() | |
1380 { | |
1381 invokeme( | |
1382 argu, | |
1383 ment); | |
1384 invokeme( | |
1385 argu, | |
1386 ment | |
1387 ); | |
1388 invokeme(argu, | |
1389 ment | |
1390 ); | |
1391 } | |
1392 | |
1393 STARTTEST | |
1394 :set cino=/6 | |
1395 2kdd]]=][ | |
1396 ENDTEST | |
1397 | |
1398 void f() | |
1399 { | |
1400 statement; | |
1401 // comment 1 | |
1402 // comment 2 | |
1403 } | |
1404 | |
1405 STARTTEST | |
1406 :set cino= | |
1407 2kdd]]/comment 1/+1 | |
1408 == | |
1409 ENDTEST | |
1410 | |
1411 void f() | |
1412 { | |
1413 statement; | |
1414 // comment 1 | |
1415 // comment 2 | |
1416 } | |
1417 | |
1418 STARTTEST | |
1419 :set cino=g0 | |
1420 2kdd]]=][ | |
1421 ENDTEST | |
1422 | |
1423 class CAbc | |
1424 { | |
1425 int Test() { return FALSE; } | |
1426 | |
1427 public: // comment | |
1428 void testfall(); | |
1429 protected: | |
1430 void testfall(); | |
1431 }; | |
1432 | |
1433 STARTTEST | |
3123 | 1434 :set cino=(0,gs,hs |
1435 2kdd]]=][ | |
1436 ENDTEST | |
1437 | |
1438 class Foo : public Bar | |
1439 { | |
1440 public: | |
1441 virtual void method1(void) = 0; | |
1442 virtual void method2(int arg1, | |
1443 int arg2, | |
1444 int arg3) = 0; | |
1445 }; | |
1446 | |
1447 STARTTEST | |
828 | 1448 :set cino=+20 |
1449 2kdd]]=][ | |
1450 ENDTEST | |
1451 | |
1452 void | |
1453 foo() | |
1454 { | |
1455 if (a) | |
1456 { | |
1457 } else | |
1458 asdf; | |
1459 } | |
1460 | |
1461 STARTTEST | |
7 | 1462 :set cino=(0,W2s |
1463 2kdd]]=][ | |
1464 ENDTEST | |
1465 | |
1466 { | |
1467 averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( | |
1468 asdasdf, | |
1469 func(asdf, | |
1470 asdfadsf), | |
1471 asdfasdf | |
1472 ); | |
1473 | |
1474 /* those are ugly, but consequent */ | |
1475 | |
1476 func()->asd(asdasdf, | |
1477 averylongfunctionname( | |
1478 abc, | |
1479 dec)->averylongfunctionname( | |
1480 asdfadsf, | |
1481 asdfasdf, | |
1482 asdfasdf, | |
1483 ), | |
1484 func(asdfadf, | |
1485 asdfasdf | |
1486 ), | |
1487 asdasdf | |
1488 ); | |
1489 | |
1490 averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( | |
1491 abc, | |
1492 dec)->asdfasdfasdf( | |
1493 asdfadsf, | |
1494 asdfasdf, | |
1495 asdfasdf, | |
1496 ), | |
1497 func(asdfadf, | |
1498 asdfasdf), | |
1499 asdasdf | |
1500 ); | |
1501 } | |
1502 | |
1503 STARTTEST | |
829 | 1504 :set cino=M1 |
1505 2kdd]]=][ | |
1506 ENDTEST | |
1507 | |
1508 int main () | |
1509 { | |
1510 if (cond1 && | |
1511 cond2 | |
1512 ) | |
1513 foo; | |
1514 } | |
1515 | |
1516 STARTTEST | |
2776 | 1517 :set cino=(0,ts |
6030 | 1518 2kdd2j=][ |
2776 | 1519 ENDTEST |
1520 | |
1521 void func(int a | |
1522 #if defined(FOO) | |
1523 , int b | |
1524 , int c | |
1525 #endif | |
1526 ) | |
1527 { | |
1528 } | |
1529 | |
1530 STARTTEST | |
1531 :set cino=(0 | |
6030 | 1532 2kdd2j=][ |
2776 | 1533 ENDTEST |
1534 | |
1535 void | |
1536 func(int a | |
1537 #if defined(FOO) | |
1538 , int b | |
1539 , int c | |
1540 #endif | |
1541 ) | |
1542 { | |
1543 } | |
1544 | |
1545 STARTTEST | |
2805 | 1546 :set cino& |
6030 | 1547 2kdd2j=7][ |
2805 | 1548 ENDTEST |
1549 | |
1550 void func(void) | |
1551 { | |
1552 if(x==y) | |
1553 if(y==z) | |
1554 foo=1; | |
1555 else { bar=1; | |
1556 baz=2; | |
1557 } | |
1558 printf("Foo!\n"); | |
1559 } | |
1560 | |
2843 | 1561 void func1(void) |
1562 { | |
1563 char* tab[] = {"foo", "bar", | |
1564 "baz", "quux", | |
1565 "this line used", "to be indented incorrectly"}; | |
1566 foo(); | |
1567 } | |
1568 | |
1569 void func2(void) | |
1570 { | |
1571 int tab[] = | |
1572 {1, 2, | |
1573 3, 4, | |
1574 5, 6}; | |
1575 | |
1576 printf("This line used to be indented incorrectly.\n"); | |
1577 } | |
1578 | |
3186 | 1579 int foo[] |
1580 #ifdef BAR | |
1581 | |
1582 = { 1, 2, 3, | |
1583 4, 5, 6 } | |
1584 | |
1585 #endif | |
1586 ; | |
1587 int baz; | |
1588 | |
2843 | 1589 void func3(void) |
1590 { | |
1591 int tab[] = { | |
1592 1, 2, | |
1593 3, 4, | |
1594 5, 6}; | |
1595 | |
3220 | 1596 printf("Don't you dare indent this line incorrectly!\n"); |
1597 } | |
1598 | |
1599 void | |
1600 func4(a, b, | |
1601 c) | |
1602 int a; | |
1603 int b; | |
1604 int c; | |
1605 { | |
1606 } | |
1607 | |
1608 void | |
1609 func5( | |
1610 int a, | |
1611 int b) | |
1612 { | |
1613 } | |
1614 | |
1615 void | |
1616 func6( | |
1617 int a) | |
1618 { | |
2843 | 1619 } |
1620 | |
2805 | 1621 STARTTEST |
2807 | 1622 :set cino& |
2953 | 1623 :set cino+=l1 |
6030 | 1624 2kdd2j=][ |
2953 | 1625 ENDTEST |
1626 | |
1627 void func(void) | |
1628 { | |
1629 int tab[] = | |
1630 { | |
1631 1, 2, 3, | |
1632 4, 5, 6}; | |
1633 | |
1634 printf("Indent this line correctly!\n"); | |
1635 | |
1636 switch (foo) | |
1637 { | |
1638 case bar: | |
1639 printf("bar"); | |
1640 break; | |
1641 case baz: { | |
1642 printf("baz"); | |
1643 break; | |
1644 } | |
1645 case quux: | |
1646 printf("But don't break the indentation of this instruction\n"); | |
1647 break; | |
1648 } | |
1649 } | |
1650 | |
1651 STARTTEST | |
1652 :set cino& | |
6030 | 1653 2kdd2j=][ |
2807 | 1654 ENDTEST |
1655 | |
1656 void func(void) | |
1657 { | |
1658 cout << "a" | |
1659 << "b" | |
1660 << ") :" | |
1661 << "c"; | |
1662 } | |
1663 | |
1664 STARTTEST | |
2809 | 1665 :set com=s1:/*,m:*,ex:*/ |
1666 ]]3jofoo(); | |
1667 ENDTEST | |
1668 | |
1669 void func(void) | |
1670 { | |
1671 /* | |
1672 * This is a comment. | |
1673 */ | |
1674 } | |
1675 | |
1676 STARTTEST | |
2855 | 1677 :set cino& |
6030 | 1678 2kdd2j=][ |
2855 | 1679 ENDTEST |
1680 | |
1681 void func(void) | |
1682 { | |
1683 for (int i = 0; i < 10; ++i) | |
1684 if (i & 1) { | |
1685 foo(1); | |
1686 } else | |
1687 foo(0); | |
1688 baz(); | |
1689 } | |
1690 | |
1691 STARTTEST | |
3454 | 1692 :set cino=k2s,(0 |
1693 2kdd3j=][ | |
1694 ENDTEST | |
1695 | |
1696 void func(void) | |
1697 { | |
1698 if (condition1 | |
1699 && condition2) | |
1700 action(); | |
1701 function(argument1 | |
1702 && argument2); | |
1703 | |
1704 if (c1 && (c2 || | |
1705 c3)) | |
1706 foo; | |
1707 if (c1 && | |
1708 (c2 || c3)) | |
1709 { | |
1710 } | |
1711 | |
1712 if ( c1 | |
1713 && ( c2 | |
1714 || c3)) | |
1715 foo; | |
1716 func( c1 | |
1717 && ( c2 | |
1718 || c3)) | |
1719 foo; | |
1720 } | |
1721 | |
1722 STARTTEST | |
1723 :set cino=k2s,(s | |
1724 2kdd3j=][ | |
1725 ENDTEST | |
1726 | |
1727 void func(void) | |
1728 { | |
1729 if (condition1 | |
1730 && condition2) | |
1731 action(); | |
1732 function(argument1 | |
1733 && argument2); | |
1734 | |
1735 if (c1 && (c2 || | |
1736 c3)) | |
1737 foo; | |
1738 if (c1 && | |
1739 (c2 || c3)) | |
1740 { | |
1741 } | |
1742 | |
1743 if ( c1 | |
1744 && ( c2 | |
1745 || c3)) | |
1746 foo; | |
1747 func( c1 | |
1748 && ( c2 | |
1749 || c3)) | |
1750 foo; | |
1751 } | |
1752 | |
1753 STARTTEST | |
1754 :set cino=k2s,(s,U1 | |
1755 2kdd3j=][ | |
1756 ENDTEST | |
1757 | |
1758 void func(void) | |
1759 { | |
1760 if (condition1 | |
1761 && condition2) | |
1762 action(); | |
1763 function(argument1 | |
1764 && argument2); | |
1765 | |
1766 if (c1 && (c2 || | |
1767 c3)) | |
1768 foo; | |
1769 if (c1 && | |
1770 (c2 || c3)) | |
1771 { | |
1772 } | |
1773 if (c123456789 | |
1774 && (c22345 | |
1775 || c3)) | |
1776 printf("foo\n"); | |
1777 | |
1778 c = c1 && | |
1779 ( | |
1780 c2 || | |
1781 c3 | |
1782 ) && c4; | |
1783 } | |
1784 | |
1785 STARTTEST | |
1786 :set cino=k2s,(0,W4 | |
1787 2kdd3j=][ | |
1788 ENDTEST | |
1789 | |
1790 void func(void) | |
1791 { | |
1792 if (condition1 | |
1793 && condition2) | |
1794 action(); | |
1795 function(argument1 | |
1796 && argument2); | |
1797 | |
1798 if (c1 && (c2 || | |
1799 c3)) | |
1800 foo; | |
1801 if (c1 && | |
1802 (c2 || c3)) | |
1803 { | |
1804 } | |
1805 if (c123456789 | |
1806 && (c22345 | |
1807 || c3)) | |
1808 printf("foo\n"); | |
1809 | |
1810 if ( c1 | |
1811 && ( c2 | |
1812 || c3)) | |
1813 foo; | |
1814 | |
1815 a_long_line( | |
1816 argument, | |
1817 argument); | |
1818 a_short_line(argument, | |
1819 argument); | |
1820 } | |
1821 | |
1822 STARTTEST | |
1823 :set cino=k2s,u2 | |
1824 2kdd3j=][ | |
1825 ENDTEST | |
1826 | |
1827 void func(void) | |
1828 { | |
1829 if (condition1 | |
1830 && condition2) | |
1831 action(); | |
1832 function(argument1 | |
1833 && argument2); | |
1834 | |
1835 if (c1 && (c2 || | |
1836 c3)) | |
1837 foo; | |
1838 if (c1 && | |
1839 (c2 || c3)) | |
1840 { | |
1841 } | |
1842 if (c123456789 | |
1843 && (c22345 | |
1844 || c3)) | |
1845 printf("foo\n"); | |
1846 } | |
1847 | |
1848 STARTTEST | |
1849 :set cino=k2s,(0,w1 | |
1850 2kdd3j=][ | |
1851 ENDTEST | |
1852 | |
1853 void func(void) | |
1854 { | |
1855 if (condition1 | |
1856 && condition2) | |
1857 action(); | |
1858 function(argument1 | |
1859 && argument2); | |
1860 | |
1861 if (c1 && (c2 || | |
1862 c3)) | |
1863 foo; | |
1864 if (c1 && | |
1865 (c2 || c3)) | |
1866 { | |
1867 } | |
1868 if (c123456789 | |
1869 && (c22345 | |
1870 || c3)) | |
1871 printf("foo\n"); | |
1872 | |
1873 if ( c1 | |
1874 && ( c2 | |
1875 || c3)) | |
1876 foo; | |
1877 func( c1 | |
1878 && ( c2 | |
1879 || c3)) | |
1880 foo; | |
1881 } | |
1882 | |
1883 STARTTEST | |
1884 :set cino=k2,(s | |
1885 2kdd3j=][ | |
1886 ENDTEST | |
1887 | |
1888 void func(void) | |
1889 { | |
1890 if (condition1 | |
1891 && condition2) | |
1892 action(); | |
1893 function(argument1 | |
1894 && argument2); | |
1895 | |
1896 if (c1 && (c2 || | |
1897 c3)) | |
1898 foo; | |
1899 if (c1 && | |
1900 (c2 || c3)) | |
1901 { | |
1902 } | |
1903 } | |
1904 | |
1905 STARTTEST | |
2857 | 1906 :set cino=N-s |
2879 | 1907 /^NAMESPACESTART |
2857 | 1908 =/^NAMESPACEEND |
1909 ENDTEST | |
1910 | |
2879 | 1911 NAMESPACESTART |
2857 | 1912 /* valid namespaces with normal indent */ |
1913 namespace | |
1914 { | |
1915 { | |
1916 111111111111; | |
1917 } | |
1918 } | |
1919 namespace /* test */ | |
1920 { | |
1921 11111111111111111; | |
1922 } | |
1923 namespace // test | |
1924 { | |
1925 111111111111111111; | |
1926 } | |
1927 namespace | |
1928 { | |
1929 111111111111111111; | |
1930 } | |
1931 namespace test | |
1932 { | |
1933 111111111111111111; | |
1934 } | |
1935 namespace{ | |
1936 111111111111111111; | |
1937 } | |
1938 namespace test{ | |
1939 111111111111111111; | |
1940 } | |
1941 namespace { | |
1942 111111111111111111; | |
1943 } | |
1944 namespace test { | |
1945 111111111111111111; | |
1946 namespace test2 { | |
1947 22222222222222222; | |
1948 } | |
1949 } | |
1950 | |
1951 /* invalid namespaces use block indent */ | |
1952 namespace test test2 { | |
1953 111111111111111111111; | |
1954 } | |
1955 namespace11111111111 { | |
1956 111111111111; | |
1957 } | |
1958 namespace() { | |
1959 1111111111111; | |
1960 } | |
1961 namespace() | |
1962 { | |
1963 111111111111111111; | |
1964 } | |
1965 namespace test test2 | |
1966 { | |
1967 1111111111111111111; | |
1968 } | |
1969 namespace111111111 | |
1970 { | |
1971 111111111111111111; | |
1972 } | |
1973 NAMESPACEEND | |
1974 | |
1975 | |
1976 STARTTEST | |
2968 | 1977 :set cino=j1,J1 |
2879 | 1978 /^JSSTART |
1979 =/^JSEND | |
1980 ENDTEST | |
1981 | |
1982 JSSTART | |
1983 var bar = { | |
1984 foo: { | |
1985 that: this, | |
1986 some: ok, | |
1987 }, | |
1988 "bar":{ | |
1989 a : 2, | |
1990 b: "123abc", | |
1991 x: 4, | |
1992 "y": 5 | |
1993 } | |
1994 } | |
1995 JSEND | |
1996 | |
1997 STARTTEST | |
2968 | 1998 :set cino=j1,J1 |
1999 /^JSSTART | |
2000 =/^JSEND | |
2001 ENDTEST | |
2002 | |
2003 JSSTART | |
2004 var foo = [ | |
6030 | 2005 1, |
2968 | 2006 2, |
2007 3 | |
6030 | 2008 ]; |
2968 | 2009 JSEND |
2010 | |
2011 STARTTEST | |
2012 :set cino=j1,J1 | |
2013 /^JSSTART | |
2014 =/^JSEND | |
2015 ENDTEST | |
2016 | |
2017 JSSTART | |
2018 function bar() { | |
2019 var foo = [ | |
2020 1, | |
2021 2, | |
2022 3 | |
6030 | 2023 ]; |
2968 | 2024 } |
2025 JSEND | |
2026 | |
2027 STARTTEST | |
2028 :set cino=j1,J1 | |
2029 /^JSSTART | |
2030 =/^JSEND | |
2031 ENDTEST | |
2032 | |
2033 JSSTART | |
2034 (function($){ | |
2035 | |
6020 | 2036 if (cond && |
2037 cond) { | |
2038 stmt; | |
2039 } | |
6030 | 2040 window.something.left = |
2041 (width - 50 + offset) + "px"; | |
2968 | 2042 var class_name='myclass'; |
2043 | |
2044 function private_method() { | |
2045 } | |
2046 | |
2047 var public_method={ | |
2048 method: function(options,args){ | |
2049 private_method(); | |
2050 } | |
2051 } | |
2052 | |
2053 function init(options) { | |
2054 | |
2055 $(this).data(class_name+'_public',$.extend({},{ | |
2056 foo: 'bar', | |
6030 | 2057 bar: 2, |
2058 foobar: [ | |
2059 1, | |
2060 2, | |
2061 3 | |
2968 | 2062 ], |
6030 | 2063 callback: function(){ |
2064 return true; | |
2065 } | |
2968 | 2066 }, options||{})); |
2067 } | |
2068 | |
2069 $.fn[class_name]=function() { | |
2070 | |
2071 var _arguments=arguments; | |
2072 return this.each(function(){ | |
2073 | |
2074 var options=$(this).data(class_name+'_public'); | |
2075 if (!options) { | |
2076 init.apply(this,_arguments); | |
2077 | |
2078 } else { | |
2079 var method=public_method[_arguments[0]]; | |
2080 | |
2081 if (typeof(method)!='function') { | |
2082 console.log(class_name+' has no method "'+_arguments[0]+'"'); | |
2083 return false; | |
2084 } | |
2085 _arguments[0]=options; | |
2086 method.apply(this,_arguments); | |
2087 } | |
2088 }); | |
2089 } | |
2090 | |
2091 })(jQuery); | |
2092 JSEND | |
2093 | |
2094 STARTTEST | |
2095 :set cino=j1,J1 | |
2096 /^JSSTART | |
2097 =/^JSEND | |
2098 ENDTEST | |
2099 | |
2100 JSSTART | |
2101 function init(options) { | |
2102 $(this).data(class_name+'_public',$.extend({},{ | |
2103 foo: 'bar', | |
2104 bar: 2, | |
2105 foobar: [ | |
6030 | 2106 1, |
2107 2, | |
2108 3 | |
2968 | 2109 ], |
2110 callback: function(){ | |
2111 return true; | |
2112 } | |
2113 }, options||{})); | |
2114 } | |
2115 JSEND | |
2116 | |
2117 STARTTEST | |
2118 :set cino=j1,J1 | |
2119 /^JSSTART | |
2120 =/^JSEND | |
2121 ENDTEST | |
2122 | |
2123 JSSTART | |
2124 (function($){ | |
2125 function init(options) { | |
2126 $(this).data(class_name+'_public',$.extend({},{ | |
2127 foo: 'bar', | |
6030 | 2128 bar: 2, |
2129 foobar: [ | |
2130 1, | |
2131 2, | |
2132 3 | |
2968 | 2133 ], |
6030 | 2134 callback: function(){ |
2135 return true; | |
2136 } | |
2968 | 2137 }, options||{})); |
2138 } | |
2139 })(jQuery); | |
2140 JSEND | |
2141 | |
2142 STARTTEST | |
6691 | 2143 :set cino=j1,J1,+2 |
2144 /^JSSTART | |
2145 =/^JSEND | |
2146 ENDTEST | |
2147 | |
2148 JSSTART | |
2149 // Results of JavaScript indent | |
2150 // 1 | |
2151 (function(){ | |
2152 var a = [ | |
2153 'a', | |
2154 'b', | |
2155 'c', | |
2156 'd', | |
2157 'e', | |
2158 'f', | |
2159 'g', | |
2160 'h', | |
2161 'i' | |
2162 ]; | |
2163 }()) | |
2164 | |
2165 // 2 | |
2166 (function(){ | |
2167 var a = [ | |
2168 0 + | |
2169 5 * | |
2170 9 * | |
2171 'a', | |
2172 'b', | |
2173 0 + | |
2174 5 * | |
2175 9 * | |
2176 'c', | |
2177 'd', | |
2178 'e', | |
2179 'f', | |
2180 'g', | |
2181 'h', | |
2182 'i' | |
2183 ]; | |
2184 }()) | |
2185 | |
2186 // 3 | |
2187 (function(){ | |
2188 var a = [ | |
2189 0 + | |
2190 // comment 1 | |
2191 5 * | |
2192 /* comment 2 */ | |
2193 9 * | |
2194 'a', | |
2195 'b', | |
2196 0 + | |
2197 5 * | |
2198 9 * | |
2199 'c', | |
2200 'd', | |
2201 'e', | |
2202 'f', | |
2203 'g', | |
2204 'h', | |
2205 'i' | |
2206 ]; | |
2207 }()) | |
2208 | |
2209 // 4 | |
2210 { | |
2211 var a = [ | |
2212 0, | |
2213 1 | |
2214 ]; | |
2215 var b; | |
2216 var c; | |
2217 } | |
2218 | |
2219 // 5 | |
2220 { | |
2221 var a = [ | |
2222 [ | |
2223 0 | |
2224 ], | |
2225 2, | |
2226 3 | |
2227 ]; | |
2228 } | |
2229 | |
2230 // 6 | |
2231 { | |
2232 var a = [ | |
2233 [ | |
2234 0, | |
2235 1 | |
2236 ], | |
2237 2, | |
2238 3 | |
2239 ]; | |
2240 } | |
2241 | |
2242 // 7 | |
2243 { | |
2244 var a = [ | |
2245 // [ | |
2246 0, | |
2247 // 1 | |
2248 // ], | |
2249 2, | |
2250 3 | |
2251 ]; | |
2252 } | |
2253 | |
2254 // 8 | |
2255 var x = [ | |
2256 (function(){ | |
2257 var a, | |
2258 b, | |
2259 c, | |
2260 d, | |
2261 e, | |
2262 f, | |
2263 g, | |
2264 h, | |
2265 i; | |
2266 }) | |
2267 ]; | |
2268 | |
2269 // 9 | |
2270 var a = [ | |
2271 0 + | |
2272 5 * | |
2273 9 * | |
2274 'a', | |
2275 'b', | |
2276 0 + | |
2277 5 * | |
2278 9 * | |
2279 'c', | |
2280 'd', | |
2281 'e', | |
2282 'f', | |
2283 'g', | |
2284 'h', | |
2285 'i' | |
2286 ]; | |
2287 | |
2288 // 10 | |
2289 var a, | |
2290 b, | |
2291 c, | |
2292 d, | |
2293 e, | |
2294 f, | |
2295 g, | |
2296 h, | |
2297 i; | |
2298 JSEND | |
2299 | |
2300 STARTTEST | |
7 | 2301 :g/^STARTTEST/.,/^ENDTEST/d |
2302 :1;/start of AUTO/,$wq! test.out | |
2303 ENDTEST |