blob: ad1db85396cfde45c7164ce474ed879a0ce8e8ec [file] [log] [blame]
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001/* start of AUTO matically checked vim: set ts=4 : */
Bram Moolenaar071d4272004-06-13 20:20:40 +00002{
3 if (test)
4 cmd1;
5 cmd2;
6}
7
8{
9 if (test)
10 cmd1;
11 else
12 cmd2;
13}
14
15{
16 if (test)
17 {
18 cmd1;
19 cmd2;
20 }
21}
22
23{
24 if (test)
25 {
26 cmd1;
27 else
28 }
29}
30
31{
32 while (this)
33 if (test)
34 cmd1;
35 cmd2;
36}
37
38{
39 while (this)
40 if (test)
41 cmd1;
42 else
43 cmd2;
44}
45
46{
47 if (test)
48 {
49 cmd;
50 }
51
52 if (test)
53 cmd;
54}
55
56{
57 if (test) {
58 cmd;
59 }
60
61 if (test) cmd;
62}
63
64{
65 cmd1;
66 for (blah)
67 while (this)
68 if (test)
69 cmd2;
70 cmd3;
71}
72
73{
74 cmd1;
75 for (blah)
76 while (this)
77 if (test)
78 cmd2;
79 cmd3;
80
81 if (test)
82 {
83 cmd1;
84 cmd2;
85 cmd3;
86 }
87}
88
89
90/* Test for 'cindent' do/while mixed with if/else: */
91
92{
93 do
94 if (asdf)
95 asdfasd;
96 while (cond);
97
98 do
99 if (asdf)
100 while (asdf)
101 asdf;
102 while (asdf);
103}
104
105/* Test for 'cindent' with two ) on a continuation line */
106{
107 if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
108 aal;sdkjf ( ;asldfkja;sldfk
109 al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
110 line up here;
111}
112
113
114/* C++ tests: */
115
116// foo() these three lines should remain in column 0
117// {
118// }
119
120/* Test for continuation and unterminated lines: */
121{
122 i = 99 + 14325 +
123 21345 +
124 21345 +
125 21345 + ( 21345 +
126 21345) +
127 2345 +
128 1234;
129 c = 1;
130}
131
132/*
133 testje for indent with empty line
134
135 here */
136
137{
138 if (testing &&
139 not a joke ||
140 line up here)
141 hay;
142 if (testing &&
143 (not a joke || testing
144 )line up here)
145 hay;
146 if (testing &&
147 (not a joke || testing
148 line up here))
149 hay;
150}
151
152
153{
154 switch (c)
155 {
156 case xx:
157 do
158 if (asdf)
159 do
160 asdfasdf;
161 while (asdf);
162 else
163 asdfasdf;
164 while (cond);
165 case yy:
166 case xx:
167 case zz:
168 testing;
169 }
170}
171
172{
173 if (cond) {
174 foo;
175 }
176 else
177 {
178 bar;
179 }
180}
181
182{
183 if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
184 alsdkfj (asldk;fj
185 awith cino=(0 ;lf this one goes to below the paren with ==
186 ;laksjfd ;lsakdjf ;alskdf asd)
187 asdfasdf;)))
188 asdfasdf;
189}
190
191 int
192func(a, b)
193 int a;
194 int c;
195{
196 if (c1 && (c2 ||
197 c3))
198 foo;
199 if (c1 &&
200 (c2 || c3)
201 )
202}
203
204{
205 while (asd)
206 {
207 if (asdf)
208 if (test)
209 if (that)
210 {
211 if (asdf)
212 do
213 cdasd;
214 while (as
215 df);
216 }
217 else
218 if (asdf)
219 asdf;
220 else
221 asdf;
222 asdf;
223 }
224}
225
226{
227 s = "/*"; b = ';'
228 s = "/*"; b = ';';
229 a = b;
230}
231
232{
233 switch (a)
234 {
235 case a:
236 switch (t)
237 {
238 case 1:
239 cmd;
240 break;
241 case 2:
242 cmd;
243 break;
244 }
245 cmd;
246 break;
247 case b:
248 {
249 int i;
250 cmd;
251 }
252 break;
253 case c: {
254 int i;
255 cmd;
256 }
257 case d: if (cond &&
258 test) { /* this line doesn't work right */
259 int i;
260 cmd;
261 }
262 break;
263 }
264}
265
266{
267 if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
268 (bp_to->b_p_initialized ||
269 (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
270 return;
271label :
272 asdf = asdf ?
273 asdf : asdf;
274 asdf = asdf ?
275 asdf: asdf;
276}
277
278/* Special Comments : This function has the added complexity (compared */
279/* : to addtolist) of having to check for a detail */
280/* : texture and add that to the list first. */
281
282char *(array[100]) = {
283 "testje",
284 "foo",
285 "bar",
286}
287
288enum soppie
289{
290 yes = 0,
291 no,
292 maybe
293};
294
295typedef enum soppie
296{
297 yes = 0,
298 no,
299 maybe
300};
301
Bram Moolenaara5285652011-12-14 20:05:21 +0100302static enum
303{
304 yes = 0,
305 no,
306 maybe
307} soppie;
308
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309{
310 int a,
311 b;
312}
313
314{
315 struct Type
316 {
317 int i;
318 char *str;
319 } var[] =
320 {
321 0, "zero",
322 1, "one",
323 2, "two",
324 3, "three"
325 };
326
327 float matrix[3][3] =
328 {
329 {
330 0,
331 1,
332 2
333 },
334 {
335 3,
336 4,
337 5
338 },
339 {
340 6,
341 7,
342 8
343 }
344 };
345}
346
347{
348 /* blah ( blah */
349 /* where does this go? */
350
351 /* blah ( blah */
352 cmd;
353
354 func(arg1,
355 /* comment */
356 arg2);
357 a;
358 {
359 b;
360 {
361 c; /* Hey, NOW it indents?! */
362 }
363 }
364
365 {
366 func(arg1,
367 arg2,
368 arg3);
369 /* Hey, what am I doing here? Is this coz of the ","? */
370 }
371}
372
373main ()
374{
375 if (cond)
376 {
377 a = b;
378 }
379 if (cond) {
380 a = c;
381 }
382 if (cond)
383 a = d;
384 return;
385}
386
387{
388 case 2: if (asdf &&
389 asdfasdf)
390 aasdf;
391 a = 9;
392 case 3: if (asdf)
393 aasdf;
394 a = 9;
395 case 4: x = 1;
396 y = 2;
397
398label: if (asdf)
399 here;
400
401label: if (asdf &&
402 asdfasdf)
403 {
404 }
405
406label: if (asdf &&
407 asdfasdf) {
408 there;
409 }
410
411label: if (asdf &&
412 asdfasdf)
413 there;
414}
415
416{
417 /*
418 hello with ":set comments= cino=c5"
419 */
420
421 /*
422 hello with ":set comments= cino="
423 */
424}
425
426
427{
428 if (a < b) {
429 a = a + 1;
430 } else
431 a = a + 2;
432
433 if (a)
434 do {
435 testing;
436 } while (asdfasdf);
437 a = b + 1;
438 asdfasdf
439}
440
441class bob
442{
443 int foo() {return 1;}
444 int bar;
445}
446
447main()
448{
449 while(1)
450 if (foo)
451 {
452 bar;
453 }
454 else {
455 asdf;
456 }
457 misplacedline;
458}
459
460{
461 if (clipboard.state == SELECT_DONE
462 && ((row == clipboard.start.lnum
463 && col >= clipboard.start.col)
464 || row > clipboard.start.lnum))
465}
466
467{
468 if (1) {i += 4;}
469 where_am_i;
470 return 0;
471}
472
473{
474 {
475 } // sdf(asdf
476 if (asdf)
477 asd;
478}
479
480{
481label1:
482label2:
483}
484
485{
486 int fooRet = foo(pBar1, false /*fKB*/,
487 true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
488 f() {
489 for ( i = 0;
490 i < m;
491 /* c */ i++ ) {
492 a = b;
493 }
494 }
495}
496
497{
498 f1(/*comment*/);
499 f2();
500}
501
502{
503 do {
504 if (foo) {
505 } else
506 ;
507 } while (foo);
508 foo(); // was wrong
509}
510
511int x; // no extra indent because of the ;
512void func()
513{
514}
515
516char *tab[] = {"aaa",
517 "};", /* }; */ NULL}
518 int indented;
519{}
520
521char *a[] = {"aaa", "bbb",
522 "ccc", NULL};
523// here
524
525char *tab[] = {"aaa",
526 "xx", /* xx */}; /* asdf */
527int not_indented;
528
529{
530 do {
531 switch (bla)
532 {
533 case 1: if (foo)
534 bar;
535 }
536 } while (boo);
537 wrong;
538}
539
540int foo,
541 bar;
542int foo;
543
544#if defined(foo) \
545 && defined(bar)
546char * xx = "asdf\
547 foo\
548 bor";
549int x;
550
551char *foo = "asdf\
552 asdf\
553 asdf",
554 *bar;
555
556void f()
557{
558#if defined(foo) \
559 && defined(bar)
560 char *foo = "asdf\
561 asdf\
562 asdf",
563 *bar;
564 {
565 int i;
566 char *foo = "asdf\
567 asdf\
568 asdf",
569 *bar;
570 }
571#endif
572}
573#endif
574
575int y; // comment
576// comment
577
578// comment
579
580{
581 Constructor(int a,
582 int b ) : BaseClass(a)
583 {
584 }
585}
586
587void foo()
588{
589 char one,
590 two;
591 struct bla piet,
592 jan;
593 enum foo kees,
594 jannie;
595 static unsigned sdf,
596 krap;
597 unsigned int piet,
598 jan;
599 int
600 kees,
601 jan;
602}
603
604{
605 t(int f,
606 int d); // )
607 d();
608}
609
610Constructor::Constructor(int a,
611 int b
612 ) :
613 BaseClass(a,
614 b,
615 c),
616 mMember(b),
617{
618}
619
620Constructor::Constructor(int a,
621 int b ) :
622 BaseClass(a)
623{
624}
625
626Constructor::Constructor(int a,
627 int b ) /*x*/ : /*x*/ BaseClass(a),
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000628 member(b)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000629{
630}
631
632class CAbc :
633 public BaseClass1,
634 protected BaseClass2
635{
636 int Test() { return FALSE; }
637 int Test1() { return TRUE; }
638
639 CAbc(int a, int b ) :
640 BaseClass(a)
641 {
642 switch(xxx)
643 {
644 case abc:
645 asdf();
646 break;
647
648 case 999:
649 baer();
650 break;
651 }
652 }
653
654 public: // <-- this was incoreectly indented before!!
655 void testfall();
656 protected:
657 void testfall();
658};
659
660class CAbc : public BaseClass1,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000661 protected BaseClass2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662{
663};
664
665static struct
666{
667 int a;
668 int b;
669} variable[COUNT] =
670{
671 {
672 123,
673 456
674 },
675 {
676 123,
677 456
678 }
679};
680
681static struct
682{
683 int a;
684 int b;
685} variable[COUNT] =
686{
687 { 123, 456 },
688 { 123, 456 }
689};
690
691void asdf() /* ind_maxparen may cause trouble here */
692{
693 if ((0
694 && 1
695 && 1
696 && 1
697 && 1
698 && 1
699 && 1
700 && 1
701 && 1
702 && 1
703 && 1
704 && 1
705 && 1
706 && 1
707 && 1
708 && 1
709 && 1
710 && 1
711 && 1
712 && 1
713 && 1
714 && 1
715 && 1
716 && 1
717 && 1
718 && 1)) break;
719}
720
Bram Moolenaar18144c82006-04-12 21:52:12 +0000721foo()
722{
723 a = cond ? foo() : asdf
724 + asdf;
725
726 a = cond ?
727 foo() : asdf
728 + asdf;
729}
730
731int main(void)
732{
733 if (a)
734 if (b)
735 2;
736 else 3;
737 next_line_of_code();
738}
739
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000740barry()
741{
742 Foo::Foo (int one,
743 int two)
744 : something(4)
745 {}
746}
747
748barry()
749{
750 Foo::Foo (int one, int two)
751 : something(4)
752 {}
753}
754
755Constructor::Constructor(int a,
756 int b
757 ) :
758 BaseClass(a,
759 b,
760 c),
761 mMember(b)
762{
763}
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000764int main ()
765{
766 if (lala)
767 do
768 ++(*lolo);
769 while (lili
770 && lele);
771 lulu;
772}
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000773
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000774int main ()
775{
776 switch (c)
777 {
778 case 'c': if (cond)
779 {
780 }
781 }
782}
783
784main()
785{
786 (void) MyFancyFuasdfadsfnction(
787 argument);
788}
789
790main()
791{
792 char foo[] = "/*";
793 /* as
794 df */
795 hello
796}
Bram Moolenaared38b0a2011-05-25 15:16:18 +0200797
798/* valid namespaces with normal indent */
799namespace
800{
801 {
802 111111111111;
803 }
804}
805namespace /* test */
806{
807 11111111111111111;
808}
809namespace // test
810{
811 111111111111111111;
812}
813namespace
814{
815 111111111111111111;
816}
817namespace test
818{
819 111111111111111111;
820}
821namespace{
822 111111111111111111;
823}
824namespace test{
825 111111111111111111;
826}
827namespace {
828 111111111111111111;
829}
830namespace test {
831 111111111111111111;
832 namespace test2 {
833 22222222222222222;
834 }
835}
836
837/* invalid namespaces use block indent */
838namespace test test2 {
839 111111111111111111111;
840}
841namespace11111111111 {
842 111111111111;
843}
844namespace() {
845 1111111111111;
846}
847namespace()
848{
849 111111111111111111;
850}
851namespace test test2
852{
853 1111111111111111111;
854}
855namespace111111111
856{
857 111111111111111111;
858}
859
Bram Moolenaar071d4272004-06-13 20:20:40 +0000860/* end of AUTO */
861
862
863{
864
865/* this is
866 * a real serious
867 * about life, the
868 * universe, and the
869 * rest important big
870 * comment
871 */
872 /* insert " about life, the universe, and the rest" after "serious" */
873}
874
875
876{
877 /*
878 * Testing for comments, without 'cin' set
879 */
880about life
881
882/*
883* what happens here?
884*/
885there
886
887 /*
888 the end of the comment, try inserting a line below */
889line
890
891 /* how about
892hello
893 this one */
894}
895
896
897{
898 var = this + that + vec[0] * vec[0]
899 + vec[1] * vec[1]
900 + vec2[2] * vec[2];
901}
902
903
904{
905 asdf asdflkajds f;
906 if (tes & ting) {
907 asdf asdf asdf ;
908 asdfa sdf asdf;
909 }
910 testing1;
911 if (tes & ting)
912 {
913 asdf asdf asdf ;
914 asdfa sdf asdf;
915 }
916 testing2;
917}
918
919
920main ( int first_par, /*
921 * Comment for
922 * first par
923 */
924 int second_par /*
925 * Comment for
926 * second par
927 */
928 )
929{
930 func( first_par, /*
931 * Comment for
932 * first par
933 */
934 second_par /*
935 * Comment for
936 * second par
937 */
938 );
939
940}
941
942
943{
944 do
945 {
946 if ()
947 {
948 if ()
949 asdf;
950 else
951 asdf;
952 }
953 } while ();
954 cmd; /* this should go under the } */
955}
956
957
958void f()
959{
960 if ( k() ) {
961 l();
962
963 } else { /* Start (two words) end */
964 m();
965 }
966
967 n();
968}
969
970
971void f()
972 {
973 if ( k() )
974 {
975 l();
976 } else { /* Start (two words) end */
977 m();
978 }
979 n(); /* should be under the if () */
980}
981
982
983void bar(void)
984 {
985 static array[2][2] =
986 {
987 { 1, 2 },
988 { 3, 4 },
989 }
990
991 while (a)
992 {
993 foo(&a);
994 }
995
996 {
997 int a;
998 {
999 a = a + 1;
1000 }
1001 }
1002 b = a;
1003 }
1004
1005void func(void)
1006 {
1007 a = 1;
1008 {
1009 b = 2;
1010 }
1011 c = 3;
1012 d = 4;
1013 }
1014/* foo */
1015
1016
1017a()
1018{
1019 do {
1020 a = a +
1021 a;
1022 } while ( a ); /* add text under this line */
1023 here
1024 if ( a )
1025 a;
1026}
1027
1028
1029a()
1030{
1031label1:
1032 /* hmm */
1033 // comment
1034label2: b();
1035label3 /* post */:
1036/* pre */ label4:
1037 f(/*com*/);
1038 if (/*com*/)
1039 cmd();
1040}
1041
1042
1043/*
1044 * A simple comment
1045 */
1046
1047/*
1048** A different comment
1049*/
1050
1051
1052void f()
1053{
1054
1055 /*********
1056 A comment.
1057 *********/
1058}
1059
1060
1061void f()
1062{
1063
1064 /*********
1065 A comment.
1066 *********/
1067}
1068
1069
1070void f()
1071{
1072 c = c1 &&
1073 (
1074 c2 ||
1075 c3
1076 ) && c4;
1077}
1078
1079
1080void f()
1081{
1082 c = c1 &&
1083 (
1084 c2 ||
1085 c3
1086 ) && c4;
1087}
1088
1089
1090void f()
1091{
1092 c = c1 &&
1093 (
1094 c2 ||
1095 c3
1096 ) && c4;
1097}
1098
1099
1100void f()
1101{
1102 if ( c1
1103 && ( c2
1104 || c3))
1105 foo;
1106}
1107
1108
1109void f()
1110{
1111 if ( c1
1112 && ( c2
1113 || c3))
1114 foo;
1115}
1116
1117
1118void f()
1119{
1120 c = c1 && (
1121 c2 ||
1122 c3
1123 ) && c4;
1124 if (
1125 c1 && c2
1126 )
1127 foo;
1128}
1129
1130
1131void f()
1132{
1133 c = c1 && (
1134 c2 ||
1135 c3
1136 ) && c4;
1137 if (
1138 c1 && c2
1139 )
1140 foo;
1141}
1142
1143
1144void f()
1145{
1146 switch (x)
1147 {
1148 case 1:
1149 a = b;
1150 break;
1151 default:
1152 a = 0;
1153 break;
1154 }
1155}
1156
1157
1158void f()
1159{
1160 invokeme(
1161 argu,
1162 ment);
1163 invokeme(
1164 argu,
1165 ment
1166 );
1167 invokeme(argu,
1168 ment
1169 );
1170}
1171
1172
1173void f()
1174{
1175 statement;
1176 // comment 1
1177 // comment 2
1178}
1179
1180
1181void f()
1182{
1183 statement;
1184 // comment 1
1185 // comment 2
1186}
1187
1188
1189class CAbc
1190{
1191 int Test() { return FALSE; }
1192
1193public: // comment
1194 void testfall();
1195protected:
1196 void testfall();
1197};
1198
1199
Bram Moolenaare79d1532011-10-04 18:03:47 +02001200class Foo : public Bar
1201{
1202 public:
1203 virtual void method1(void) = 0;
1204 virtual void method2(int arg1,
1205 int arg2,
1206 int arg3) = 0;
1207};
1208
1209
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00001210 void
1211foo()
1212{
1213 if (a)
1214 {
1215 } else
1216 asdf;
1217}
1218
1219
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220{
1221 averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
1222 asdasdf,
1223 func(asdf,
1224 asdfadsf),
1225 asdfasdf
1226 );
1227
1228 /* those are ugly, but consequent */
1229
1230 func()->asd(asdasdf,
1231 averylongfunctionname(
1232 abc,
1233 dec)->averylongfunctionname(
1234 asdfadsf,
1235 asdfasdf,
1236 asdfasdf,
1237 ),
1238 func(asdfadf,
1239 asdfasdf
1240 ),
1241 asdasdf
1242 );
1243
1244 averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
1245 abc,
1246 dec)->asdfasdfasdf(
1247 asdfadsf,
1248 asdfasdf,
1249 asdfasdf,
1250 ),
1251 func(asdfadf,
1252 asdfasdf),
1253 asdasdf
1254 );
1255}
1256
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001257
1258int main ()
1259{
1260 if (cond1 &&
1261 cond2
1262 )
1263 foo;
1264}
1265
Bram Moolenaar8d2d71d2011-04-28 13:02:09 +02001266
1267void func(int a
1268#if defined(FOO)
1269 , int b
1270 , int c
1271#endif
1272 )
1273{
1274}
1275
1276
1277 void
1278func(int a
1279#if defined(FOO)
1280 , int b
1281 , int c
1282#endif
1283 )
1284{
1285}
1286
Bram Moolenaar4ae06c12011-05-10 11:39:19 +02001287
1288void func(void)
1289{
1290 if(x==y)
1291 if(y==z)
1292 foo=1;
1293 else { bar=1;
1294 baz=2;
1295 }
1296 printf("Foo!\n");
1297}
1298
Bram Moolenaar496f9512011-05-19 16:35:09 +02001299void func1(void)
1300{
1301 char* tab[] = {"foo", "bar",
1302 "baz", "quux",
1303 "this line used", "to be indented incorrectly"};
1304 foo();
1305}
1306
1307void func2(void)
1308{
1309 int tab[] =
1310 {1, 2,
1311 3, 4,
1312 5, 6};
1313
1314 printf("This line used to be indented incorrectly.\n");
1315}
1316
Bram Moolenaar3388bb42011-11-30 17:20:23 +01001317int foo[]
1318#ifdef BAR
1319
1320= { 1, 2, 3,
1321 4, 5, 6 }
1322
1323#endif
1324 ;
1325int baz;
1326
Bram Moolenaar496f9512011-05-19 16:35:09 +02001327void func3(void)
1328{
1329 int tab[] = {
1330 1, 2,
1331 3, 4,
1332 5, 6};
1333
1334 printf("Don't you dare indent this line incorrectly!\n);
1335}
1336
Bram Moolenaaraede6ce2011-05-10 11:56:30 +02001337
1338void func(void)
1339{
Bram Moolenaar50f42ca2011-07-15 14:12:30 +02001340 int tab[] =
1341 {
1342 1, 2, 3,
1343 4, 5, 6};
1344
1345 printf("Indent this line correctly!\n");
1346
1347 switch (foo)
1348 {
1349 case bar:
1350 printf("bar");
1351 break;
1352 case baz: {
1353 printf("baz");
1354 break;
1355 }
1356 case quux:
1357 printf("But don't break the indentation of this instruction\n");
1358 break;
1359 }
1360}
1361
1362
1363void func(void)
1364{
Bram Moolenaaraede6ce2011-05-10 11:56:30 +02001365 cout << "a"
1366 << "b"
1367 << ") :"
1368 << "c";
1369}
1370
Bram Moolenaara4271d52011-05-10 13:38:27 +02001371
1372void func(void)
1373{
1374 /*
1375 * This is a comment.
1376 */
1377 foo();
1378}
1379
Bram Moolenaar334adf02011-05-25 13:34:04 +02001380
1381void func(void)
1382{
1383 for (int i = 0; i < 10; ++i)
1384 if (i & 1) {
1385 foo(1);
1386 } else
1387 foo(0);
1388 baz();
1389}
1390
Bram Moolenaared38b0a2011-05-25 15:16:18 +02001391
Bram Moolenaar6ec154b2011-06-12 21:51:08 +02001392NAMESPACESTART
Bram Moolenaared38b0a2011-05-25 15:16:18 +02001393/* valid namespaces with normal indent */
1394namespace
1395{
1396{
1397 111111111111;
1398}
1399}
1400namespace /* test */
1401{
140211111111111111111;
1403}
1404namespace // test
1405{
1406111111111111111111;
1407}
1408namespace
1409{
1410111111111111111111;
1411}
1412namespace test
1413{
1414111111111111111111;
1415}
1416namespace{
1417111111111111111111;
1418}
1419namespace test{
1420111111111111111111;
1421}
1422namespace {
1423111111111111111111;
1424}
1425namespace test {
1426111111111111111111;
1427namespace test2 {
142822222222222222222;
1429}
1430}
1431
1432/* invalid namespaces use block indent */
1433namespace test test2 {
1434 111111111111111111111;
1435}
1436namespace11111111111 {
1437 111111111111;
1438}
1439namespace() {
1440 1111111111111;
1441}
1442namespace()
1443{
1444 111111111111111111;
1445}
1446namespace test test2
1447{
1448 1111111111111111111;
1449}
1450namespace111111111
1451{
1452 111111111111111111;
1453}
1454NAMESPACEEND
1455
1456
Bram Moolenaar6ec154b2011-06-12 21:51:08 +02001457
1458JSSTART
1459var bar = {
1460 foo: {
1461 that: this,
1462 some: ok,
1463 },
1464 "bar":{
1465 a : 2,
1466 b: "123abc",
1467 x: 4,
1468 "y": 5
1469 }
1470}
1471JSEND
1472
Bram Moolenaar76f7fd32011-07-20 15:09:43 +02001473
1474JSSTART
1475var foo = [
14761, // indent 8 more
1477 2,
1478 3
1479 ]; // indent 8 less
1480JSEND
1481
1482
1483JSSTART
1484function bar() {
1485 var foo = [
1486 1,
1487 2,
1488 3
1489 ]; // indent 16 less
1490}
1491JSEND
1492
1493
1494JSSTART
1495(function($){
1496
1497 var class_name='myclass';
1498
1499 function private_method() {
1500 }
1501
1502 var public_method={
1503 method: function(options,args){
1504 private_method();
1505 }
1506 }
1507
1508 function init(options) {
1509
1510 $(this).data(class_name+'_public',$.extend({},{
1511 foo: 'bar',
1512 bar: 2, // indent 8 more
1513 foobar: [ // indent 8 more
1514 1, // indent 8 more
1515 2, // indent 16 more
1516 3 // indent 16 more
1517 ],
1518 callback: function(){ // indent 8 more
1519 return true; // indent 8 more
1520 } // indent 8 more
1521 }, options||{}));
1522 }
1523
1524 $.fn[class_name]=function() {
1525
1526 var _arguments=arguments;
1527 return this.each(function(){
1528
1529 var options=$(this).data(class_name+'_public');
1530 if (!options) {
1531 init.apply(this,_arguments);
1532
1533 } else {
1534 var method=public_method[_arguments[0]];
1535
1536 if (typeof(method)!='function') {
1537 console.log(class_name+' has no method "'+_arguments[0]+'"');
1538 return false;
1539 }
1540 _arguments[0]=options;
1541 method.apply(this,_arguments);
1542 }
1543 });
1544 }
1545
1546})(jQuery);
1547JSEND
1548
1549
1550JSSTART
1551function init(options) {
1552 $(this).data(class_name+'_public',$.extend({},{
1553 foo: 'bar',
1554 bar: 2,
1555 foobar: [
1556 1, // indent 8 more
1557 2, // indent 8 more
1558 3 // indent 8 more
1559 ],
1560 callback: function(){
1561 return true;
1562 }
1563 }, options||{}));
1564}
1565JSEND
1566
1567
1568JSSTART
1569(function($){
1570 function init(options) {
1571 $(this).data(class_name+'_public',$.extend({},{
1572 foo: 'bar',
1573 bar: 2, // indent 8 more
1574 foobar: [ // indent 8 more
1575 1, // indent 8 more
1576 2, // indent 16 more
1577 3 // indent 16 more
1578 ],
1579 callback: function(){ // indent 8 more
1580 return true; // indent 8 more
1581 } // indent 8 more
1582 }, options||{}));
1583 }
1584})(jQuery);
1585JSEND
1586