Created
January 7, 2017 12:33
-
-
Save h-east/8e5fb53b928d4ac1ab7e0e9cadcf5f80 to your computer and use it in GitHub Desktop.
Vim's test3(old style test) convert to test_cindent.vim(new style test) [WIP]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Makefile b/src/Makefile | |
index 4b29ae1..8283c33 100644 | |
--- a/src/Makefile | |
+++ b/src/Makefile | |
@@ -2083,6 +2083,7 @@ test_arglist \ | |
test_cdo \ | |
test_channel \ | |
test_charsearch \ | |
+ test_cindent \ | |
test_cmdline \ | |
test_command_count \ | |
test_crypt \ | |
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak | |
index 072c61c..8987d8b 100644 | |
--- a/src/testdir/Make_all.mak | |
+++ b/src/testdir/Make_all.mak | |
@@ -143,6 +143,7 @@ NEW_TESTS = test_arglist.res \ | |
test_cdo.res \ | |
test_channel.res \ | |
test_charsearch.res \ | |
+ test_cindent.res \ | |
test_cmdline.res \ | |
test_crypt.res \ | |
test_cscope.res \ | |
diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim | |
new file mode 100644 | |
index 0000000..279e734 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent.vim | |
@@ -0,0 +1,24 @@ | |
+" Test for 'cindent' | |
+ | |
+if !has('cindent') | |
+ finish | |
+endif | |
+ | |
+func SetUp() | |
+ new | |
+ set cin ts=4 sw=4 modeline | |
+endfunc | |
+ | |
+func TearDown() | |
+ quit! | |
+endfunc | |
+ | |
+func Test_cindent() | |
+ edit test_cindent/test_001.txt | |
+ let except = getline(1, '$') | |
+ norm! gg=G | |
+ call assert_equal(except, getline(1, '$')) | |
+ call assert_equal([1,2], [1,22]) | |
+endfunc | |
+ | |
+" vim: shiftwidth=2 sts=2 expandtab | |
diff --git a/src/testdir/test_cindent/test3_result.txt b/src/testdir/test_cindent/test3_result.txt | |
new file mode 100644 | |
index 0000000..0fd8823 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test3_result.txt | |
@@ -0,0 +1,2142 @@ | |
+/* vim: set cin ts=4 sw=4 : */ | |
+ | |
+Test for 'cindent' | |
+ | |
+ENDTEST | |
+ | |
+/* start of AUTO matically checked vim: set ts=4 : */ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ else | |
+ } | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) | |
+ cmd; | |
+} | |
+ | |
+{ | |
+ if (test) { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) cmd; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ cmd3; | |
+ } | |
+} | |
+ | |
+ | |
+/* Test for 'cindent' do/while mixed with if/else: */ | |
+ | |
+{ | |
+ do | |
+ if (asdf) | |
+ asdfasd; | |
+ while (cond); | |
+ | |
+ do | |
+ if (asdf) | |
+ while (asdf) | |
+ asdf; | |
+ while (asdf); | |
+} | |
+ | |
+/* Test for 'cindent' with two ) on a continuation line */ | |
+{ | |
+ if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d | |
+ aal;sdkjf ( ;asldfkja;sldfk | |
+ al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) | |
+ line up here; | |
+} | |
+ | |
+ | |
+/* C++ tests: */ | |
+ | |
+// foo() these three lines should remain in column 0 | |
+// { | |
+// } | |
+ | |
+/* Test for continuation and unterminated lines: */ | |
+{ | |
+ i = 99 + 14325 + | |
+ 21345 + | |
+ 21345 + | |
+ 21345 + ( 21345 + | |
+ 21345) + | |
+ 2345 + | |
+ 1234; | |
+ c = 1; | |
+} | |
+ | |
+/* | |
+ testje for indent with empty line | |
+ | |
+ here */ | |
+ | |
+{ | |
+ if (testing && | |
+ not a joke || | |
+ line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ )line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ line up here)) | |
+ hay; | |
+} | |
+ | |
+ | |
+{ | |
+ switch (c) | |
+ { | |
+ case xx: | |
+ do | |
+ if (asdf) | |
+ do | |
+ asdfasdf; | |
+ while (asdf); | |
+ else | |
+ asdfasdf; | |
+ while (cond); | |
+ case yy: | |
+ case xx: | |
+ case zz: | |
+ testing; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (cond) { | |
+ foo; | |
+ } | |
+ else | |
+ { | |
+ bar; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf | |
+ alsdkfj (asldk;fj | |
+ awith cino=(0 ;lf this one goes to below the paren with == | |
+ ;laksjfd ;lsakdjf ;alskdf asd) | |
+ asdfasdf;))) | |
+ asdfasdf; | |
+} | |
+ | |
+ int | |
+func(a, b) | |
+ int a; | |
+ int c; | |
+{ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3) | |
+ ) | |
+} | |
+ | |
+{ | |
+ while (asd) | |
+ { | |
+ if (asdf) | |
+ if (test) | |
+ if (that) | |
+ { | |
+ if (asdf) | |
+ do | |
+ cdasd; | |
+ while (as | |
+ df); | |
+ } | |
+ else | |
+ if (asdf) | |
+ asdf; | |
+ else | |
+ asdf; | |
+ asdf; | |
+ } | |
+} | |
+ | |
+{ | |
+ s = "/*"; b = ';' | |
+ s = "/*"; b = ';'; | |
+ a = b; | |
+} | |
+ | |
+{ | |
+ switch (a) | |
+ { | |
+ case a: | |
+ switch (t) | |
+ { | |
+ case 1: | |
+ cmd; | |
+ break; | |
+ case 2: | |
+ cmd; | |
+ break; | |
+ } | |
+ cmd; | |
+ break; | |
+ case b: | |
+ { | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ case c: { | |
+ int i; | |
+ cmd; | |
+ } | |
+ case d: if (cond && | |
+ test) { /* this line doesn't work right */ | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && | |
+ (bp_to->b_p_initialized || | |
+ (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
+ return; | |
+label : | |
+ asdf = asdf ? | |
+ asdf : asdf; | |
+ asdf = asdf ? | |
+ asdf: asdf; | |
+} | |
+ | |
+/* Special Comments : This function has the added complexity (compared */ | |
+/* : to addtolist) of having to check for a detail */ | |
+/* : texture and add that to the list first. */ | |
+ | |
+char *(array[100]) = { | |
+ "testje", | |
+ "foo", | |
+ "bar", | |
+} | |
+ | |
+enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+typedef enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+public static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+static private enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+{ | |
+ int a, | |
+ b; | |
+} | |
+ | |
+{ | |
+ struct Type | |
+ { | |
+ int i; | |
+ char *str; | |
+ } var[] = | |
+ { | |
+ 0, "zero", | |
+ 1, "one", | |
+ 2, "two", | |
+ 3, "three" | |
+ }; | |
+ | |
+ float matrix[3][3] = | |
+ { | |
+ { | |
+ 0, | |
+ 1, | |
+ 2 | |
+ }, | |
+ { | |
+ 3, | |
+ 4, | |
+ 5 | |
+ }, | |
+ { | |
+ 6, | |
+ 7, | |
+ 8 | |
+ } | |
+ }; | |
+} | |
+ | |
+{ | |
+ /* blah ( blah */ | |
+ /* where does this go? */ | |
+ | |
+ /* blah ( blah */ | |
+ cmd; | |
+ | |
+ func(arg1, | |
+ /* comment */ | |
+ arg2); | |
+ a; | |
+ { | |
+ b; | |
+ { | |
+ c; /* Hey, NOW it indents?! */ | |
+ } | |
+ } | |
+ | |
+ { | |
+ func(arg1, | |
+ arg2, | |
+ arg3); | |
+ /* Hey, what am I doing here? Is this coz of the ","? */ | |
+ } | |
+} | |
+ | |
+main () | |
+{ | |
+ if (cond) | |
+ { | |
+ a = b; | |
+ } | |
+ if (cond) { | |
+ a = c; | |
+ } | |
+ if (cond) | |
+ a = d; | |
+ return; | |
+} | |
+ | |
+{ | |
+ case 2: if (asdf && | |
+ asdfasdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 3: if (asdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 4: x = 1; | |
+ y = 2; | |
+ | |
+label: if (asdf) | |
+ here; | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ { | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) { | |
+ there; | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ there; | |
+} | |
+ | |
+{ | |
+ /* | |
+ hello with ":set comments= cino=c5" | |
+ */ | |
+ | |
+ /* | |
+ hello with ":set comments= cino=" | |
+ */ | |
+} | |
+ | |
+ | |
+{ | |
+ if (a < b) { | |
+ a = a + 1; | |
+ } else | |
+ a = a + 2; | |
+ | |
+ if (a) | |
+ do { | |
+ testing; | |
+ } while (asdfasdf); | |
+ a = b + 1; | |
+ asdfasdf | |
+} | |
+ | |
+{ | |
+ for ( int i = 0; | |
+ i < 10; i++ ) | |
+ { | |
+ } | |
+ i = 0; | |
+} | |
+ | |
+class bob | |
+{ | |
+ int foo() {return 1;} | |
+ int bar; | |
+} | |
+ | |
+main() | |
+{ | |
+ while(1) | |
+ if (foo) | |
+ { | |
+ bar; | |
+ } | |
+ else { | |
+ asdf; | |
+ } | |
+ misplacedline; | |
+} | |
+ | |
+{ | |
+ if (clipboard.state == SELECT_DONE | |
+ && ((row == clipboard.start.lnum | |
+ && col >= clipboard.start.col) | |
+ || row > clipboard.start.lnum)) | |
+} | |
+ | |
+{ | |
+ if (1) {i += 4;} | |
+ where_am_i; | |
+ return 0; | |
+} | |
+ | |
+{ | |
+ { | |
+ } // sdf(asdf | |
+ if (asdf) | |
+ asd; | |
+} | |
+ | |
+{ | |
+label1: | |
+label2: | |
+} | |
+ | |
+{ | |
+ int fooRet = foo(pBar1, false /*fKB*/, | |
+ true /*fPTB*/, 3 /*nT*/, false /*fDF*/); | |
+ f() { | |
+ for ( i = 0; | |
+ i < m; | |
+ /* c */ i++ ) { | |
+ a = b; | |
+ } | |
+ } | |
+} | |
+ | |
+{ | |
+ f1(/*comment*/); | |
+ f2(); | |
+} | |
+ | |
+{ | |
+ do { | |
+ if (foo) { | |
+ } else | |
+ ; | |
+ } while (foo); | |
+ foo(); // was wrong | |
+} | |
+ | |
+int x; // no extra indent because of the ; | |
+void func() | |
+{ | |
+} | |
+ | |
+char *tab[] = {"aaa", | |
+ "};", /* }; */ NULL} | |
+ int indented; | |
+{} | |
+ | |
+char *a[] = {"aaa", "bbb", | |
+ "ccc", NULL}; | |
+// here | |
+ | |
+char *tab[] = {"aaa", | |
+ "xx", /* xx */}; /* asdf */ | |
+int not_indented; | |
+ | |
+{ | |
+ do { | |
+ switch (bla) | |
+ { | |
+ case 1: if (foo) | |
+ bar; | |
+ } | |
+ } while (boo); | |
+ wrong; | |
+} | |
+ | |
+int foo, | |
+ bar; | |
+int foo; | |
+ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+char * xx = "asdf\ | |
+ foo\ | |
+ bor"; | |
+int x; | |
+ | |
+char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ | |
+void f() | |
+{ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ { | |
+ int i; | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ } | |
+#endif | |
+} | |
+#endif | |
+ | |
+int y; // comment | |
+// comment | |
+ | |
+// comment | |
+ | |
+{ | |
+ Constructor(int a, | |
+ int b ) : BaseClass(a) | |
+ { | |
+ } | |
+} | |
+ | |
+void foo() | |
+{ | |
+ char one, | |
+ two; | |
+ struct bla piet, | |
+ jan; | |
+ enum foo kees, | |
+ jannie; | |
+ static unsigned sdf, | |
+ krap; | |
+ unsigned int piet, | |
+ jan; | |
+ int | |
+ kees, | |
+ jan; | |
+} | |
+ | |
+{ | |
+ t(int f, | |
+ int d); // ) | |
+ d(); | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b), | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) : | |
+ BaseClass(a) | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) /*x*/ : /*x*/ BaseClass(a), | |
+ member(b) | |
+{ | |
+} | |
+ | |
+A::A(int a, int b) | |
+ : aa(a), | |
+ bb(b), | |
+ cc(c) | |
+{ | |
+} | |
+ | |
+class CAbc : | |
+ public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+ int Test() { return FALSE; } | |
+ int Test1() { return TRUE; } | |
+ | |
+ CAbc(int a, int b ) : | |
+ BaseClass(a) | |
+ { | |
+ switch(xxx) | |
+ { | |
+ case abc: | |
+ asdf(); | |
+ break; | |
+ | |
+ case 999: | |
+ baer(); | |
+ break; | |
+ } | |
+ } | |
+ | |
+ public: // <-- this was incoreectly indented before!! | |
+ void testfall(); | |
+ protected: | |
+ void testfall(); | |
+}; | |
+ | |
+class CAbc : public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { | |
+ 123, | |
+ 456 | |
+ }, | |
+ { | |
+ 123, | |
+ 456 | |
+ } | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { 123, 456 }, | |
+ { 123, 456 } | |
+}; | |
+ | |
+void asdf() /* ind_maxparen may cause trouble here */ | |
+{ | |
+ if ((0 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1)) break; | |
+} | |
+ | |
+foo() | |
+{ | |
+ a = cond ? foo() : asdf | |
+ + asdf; | |
+ | |
+ a = cond ? | |
+ foo() : asdf | |
+ + asdf; | |
+} | |
+ | |
+int main(void) | |
+{ | |
+ if (a) | |
+ if (b) | |
+ 2; | |
+ else 3; | |
+ next_line_of_code(); | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, | |
+ int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b) | |
+{ | |
+} | |
+int main () | |
+{ | |
+ if (lala) | |
+ do | |
+ ++(*lolo); | |
+ while (lili | |
+ && lele); | |
+ lulu; | |
+} | |
+ | |
+int main () | |
+{ | |
+ switch (c) | |
+ { | |
+ case 'c': if (cond) | |
+ { | |
+ } | |
+ } | |
+} | |
+ | |
+main() | |
+{ | |
+ (void) MyFancyFuasdfadsfnction( | |
+ argument); | |
+} | |
+ | |
+main() | |
+{ | |
+ char foo[] = "/*"; | |
+ /* as | |
+ df */ | |
+ hello | |
+} | |
+ | |
+/* valid namespaces with normal indent */ | |
+namespace | |
+{ | |
+ { | |
+ 111111111111; | |
+ } | |
+} | |
+namespace /* test */ | |
+{ | |
+ 11111111111111111; | |
+} | |
+namespace // test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace{ | |
+ 111111111111111111; | |
+} | |
+namespace test{ | |
+ 111111111111111111; | |
+} | |
+namespace { | |
+ 111111111111111111; | |
+} | |
+namespace test { | |
+ 111111111111111111; | |
+ namespace test2 { | |
+ 22222222222222222; | |
+ } | |
+} | |
+ | |
+/* invalid namespaces use block indent */ | |
+namespace test test2 { | |
+ 111111111111111111111; | |
+} | |
+namespace11111111111 { | |
+ 111111111111; | |
+} | |
+namespace() { | |
+ 1111111111111; | |
+} | |
+namespace() | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test test2 | |
+{ | |
+ 1111111111111111111; | |
+} | |
+namespace111111111 | |
+{ | |
+ 111111111111111111; | |
+} | |
+ | |
+void getstring() { | |
+ /* Raw strings */ | |
+ const char* s = R"( | |
+ test { | |
+ # comment | |
+ field: 123 | |
+ } | |
+ )"; | |
+} | |
+ | |
+void getstring() { | |
+ const char* s = R"foo( | |
+ test { | |
+ # comment | |
+ field: 123 | |
+ } | |
+ )foo"; | |
+} | |
+ | |
+{ | |
+ int a[4] = { | |
+ [0] = 0, | |
+ [1] = 1, | |
+ [2] = 2, | |
+ [3] = 3, | |
+ }; | |
+} | |
+ | |
+{ | |
+ a = b[2] | |
+ + 3; | |
+} | |
+ | |
+{ | |
+ if (1) | |
+ /* aaaaa | |
+ * bbbbb | |
+ */ | |
+ a = 1; | |
+} | |
+ | |
+void func() | |
+{ | |
+ switch (foo) | |
+ { | |
+ case (bar): | |
+ if (baz()) | |
+ quux(); | |
+ break; | |
+ case (shmoo): | |
+ if (!bar) | |
+ { | |
+ } | |
+ case (foo1): | |
+ switch (bar) | |
+ { | |
+ case baz: | |
+ baz_f(); | |
+ break; | |
+ } | |
+ break; | |
+ default: | |
+ baz(); | |
+ baz(); | |
+ break; | |
+ } | |
+} | |
+ | |
+/* end of AUTO */ | |
+ | |
+ENDTEST | |
+ | |
+{ | |
+ | |
+/* this is | |
+ * a real serious | |
+ * about life, the | |
+ * universe, and the | |
+ * rest important big | |
+ * comment | |
+ */ | |
+ /* insert " about life, the universe, and the rest" after "serious" */ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+{ | |
+ /* | |
+ * Testing for comments, without 'cin' set | |
+ */ | |
+about life | |
+ | |
+/* | |
+* what happens here? | |
+*/ | |
+there | |
+ | |
+ /* | |
+ the end of the comment, try inserting a line below */ | |
+line | |
+ | |
+ /* how about | |
+hello | |
+ this one */ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+{ | |
+ var = this + that + vec[0] * vec[0] | |
+ + vec[1] * vec[1] | |
+ + vec2[2] * vec[2]; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+{ | |
+ asdf asdflkajds f; | |
+ if (tes & ting) { | |
+ asdf asdf asdf ; | |
+ asdfa sdf asdf; | |
+ } | |
+ testing1; | |
+ if (tes & ting) | |
+ { | |
+ asdf asdf asdf ; | |
+ asdfa sdf asdf; | |
+ } | |
+ testing2; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+main ( int first_par, /* | |
+ * Comment for | |
+ * first par | |
+ */ | |
+ int second_par /* | |
+ * Comment for | |
+ * second par | |
+ */ | |
+ ) | |
+{ | |
+ func( first_par, /* | |
+ * Comment for | |
+ * first par | |
+ */ | |
+ second_par /* | |
+ * Comment for | |
+ * second par | |
+ */ | |
+ ); | |
+ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+main(void) | |
+{ | |
+ /* Make sure that cino=X0s is not parsed like cino=Xs. */ | |
+ if (cond) | |
+ foo(); | |
+ else | |
+ { | |
+ bar(); | |
+ } | |
+} | |
+ | |
+ENDTEST | |
+ | |
+{ | |
+ do | |
+ { | |
+ if () | |
+ { | |
+ if () | |
+ asdf; | |
+ else | |
+ asdf; | |
+ } | |
+ } while (); | |
+ cmd; /* this should go under the } */ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ if ( k() ) { | |
+ l(); | |
+ | |
+ } else { /* Start (two words) end */ | |
+ m(); | |
+ } | |
+ | |
+ n(); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+ { | |
+ if ( k() ) | |
+ { | |
+ l(); | |
+ } else { /* Start (two words) end */ | |
+ m(); | |
+ } | |
+ n(); /* should be under the if () */ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void bar(void) | |
+ { | |
+ static array[2][2] = | |
+ { | |
+ { 1, 2 }, | |
+ { 3, 4 }, | |
+ } | |
+ | |
+ while (a) | |
+ { | |
+ foo(&a); | |
+ } | |
+ | |
+ { | |
+ int a; | |
+ { | |
+ a = a + 1; | |
+ } | |
+ } | |
+ b = a; | |
+ } | |
+ | |
+void func(void) | |
+ { | |
+ a = 1; | |
+ { | |
+ b = 2; | |
+ } | |
+ c = 3; | |
+ d = 4; | |
+ } | |
+/* foo */ | |
+ | |
+ENDTEST | |
+ | |
+a() | |
+{ | |
+ do { | |
+ a = a + | |
+ a; | |
+ } while ( a ); /* add text under this line */ | |
+ here | |
+ if ( a ) | |
+ a; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+a() | |
+{ | |
+label1: | |
+ /* hmm */ | |
+ // comment | |
+label2: b(); | |
+label3 /* post */: | |
+/* pre */ label4: | |
+ f(/*com*/); | |
+ if (/*com*/) | |
+ cmd(); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+/* | |
+ * A simple comment | |
+ */ | |
+ | |
+/* | |
+** A different comment | |
+*/ | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ | |
+ /********* | |
+ A comment. | |
+ *********/ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ | |
+ /********* | |
+ A comment. | |
+ *********/ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ c = c1 && ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+ if ( | |
+ c1 && c2 | |
+ ) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ c = c1 && ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+ if ( | |
+ c1 && c2 | |
+ ) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ switch (x) | |
+ { | |
+ case 1: | |
+ a = b; | |
+ break; | |
+ default: | |
+ a = 0; | |
+ break; | |
+ } | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ invokeme( | |
+ argu, | |
+ ment); | |
+ invokeme( | |
+ argu, | |
+ ment | |
+ ); | |
+ invokeme(argu, | |
+ ment | |
+ ); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ statement; | |
+ // comment 1 | |
+ // comment 2 | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void f() | |
+{ | |
+ statement; | |
+ // comment 1 | |
+ // comment 2 | |
+} | |
+ | |
+ENDTEST | |
+ | |
+class CAbc | |
+{ | |
+ int Test() { return FALSE; } | |
+ | |
+public: // comment | |
+ void testfall(); | |
+protected: | |
+ void testfall(); | |
+}; | |
+ | |
+ENDTEST | |
+ | |
+class Foo : public Bar | |
+{ | |
+ public: | |
+ virtual void method1(void) = 0; | |
+ virtual void method2(int arg1, | |
+ int arg2, | |
+ int arg3) = 0; | |
+}; | |
+ | |
+ENDTEST | |
+ | |
+ void | |
+foo() | |
+{ | |
+ if (a) | |
+ { | |
+ } else | |
+ asdf; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+{ | |
+ averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( | |
+ asdasdf, | |
+ func(asdf, | |
+ asdfadsf), | |
+ asdfasdf | |
+ ); | |
+ | |
+ /* those are ugly, but consequent */ | |
+ | |
+ func()->asd(asdasdf, | |
+ averylongfunctionname( | |
+ abc, | |
+ dec)->averylongfunctionname( | |
+ asdfadsf, | |
+ asdfasdf, | |
+ asdfasdf, | |
+ ), | |
+ func(asdfadf, | |
+ asdfasdf | |
+ ), | |
+ asdasdf | |
+ ); | |
+ | |
+ averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( | |
+ abc, | |
+ dec)->asdfasdfasdf( | |
+ asdfadsf, | |
+ asdfasdf, | |
+ asdfasdf, | |
+ ), | |
+ func(asdfadf, | |
+ asdfasdf), | |
+ asdasdf | |
+ ); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+int main () | |
+{ | |
+ if (cond1 && | |
+ cond2 | |
+ ) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(int a | |
+#if defined(FOO) | |
+ , int b | |
+ , int c | |
+#endif | |
+ ) | |
+{ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+ void | |
+func(int a | |
+#if defined(FOO) | |
+ , int b | |
+ , int c | |
+#endif | |
+ ) | |
+{ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if(x==y) | |
+ if(y==z) | |
+ foo=1; | |
+ else { bar=1; | |
+ baz=2; | |
+ } | |
+ printf("Foo!\n"); | |
+} | |
+ | |
+void func1(void) | |
+{ | |
+ char* tab[] = {"foo", "bar", | |
+ "baz", "quux", | |
+ "this line used", "to be indented incorrectly"}; | |
+ foo(); | |
+} | |
+ | |
+void func2(void) | |
+{ | |
+ int tab[] = | |
+ {1, 2, | |
+ 3, 4, | |
+ 5, 6}; | |
+ | |
+ printf("This line used to be indented incorrectly.\n"); | |
+} | |
+ | |
+int foo[] | |
+#ifdef BAR | |
+ | |
+= { 1, 2, 3, | |
+ 4, 5, 6 } | |
+ | |
+#endif | |
+ ; | |
+int baz; | |
+ | |
+void func3(void) | |
+{ | |
+ int tab[] = { | |
+ 1, 2, | |
+ 3, 4, | |
+ 5, 6}; | |
+ | |
+ printf("Don't you dare indent this line incorrectly!\n"); | |
+} | |
+ | |
+ void | |
+func4(a, b, | |
+ c) | |
+ int a; | |
+ int b; | |
+ int c; | |
+{ | |
+} | |
+ | |
+ void | |
+func5( | |
+ int a, | |
+ int b) | |
+{ | |
+} | |
+ | |
+ void | |
+func6( | |
+ int a) | |
+{ | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ int tab[] = | |
+ { | |
+ 1, 2, 3, | |
+ 4, 5, 6}; | |
+ | |
+ printf("Indent this line correctly!\n"); | |
+ | |
+ switch (foo) | |
+ { | |
+ case bar: | |
+ printf("bar"); | |
+ break; | |
+ case baz: { | |
+ printf("baz"); | |
+ break; | |
+ } | |
+ case quux: | |
+ printf("But don't break the indentation of this instruction\n"); | |
+ break; | |
+ } | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ cout << "a" | |
+ << "b" | |
+ << ") :" | |
+ << "c"; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ /* | |
+ * This is a comment. | |
+ */ | |
+ foo(); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ for (int i = 0; i < 10; ++i) | |
+ if (i & 1) { | |
+ foo(1); | |
+ } else | |
+ foo(0); | |
+ baz(); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ func( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ func( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ | |
+ a_long_line( | |
+ argument, | |
+ argument); | |
+ a_short_line(argument, | |
+ argument); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ func( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
+ENDTEST | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+} | |
+ | |
+ENDTEST | |
+ | |
+NAMESPACESTART | |
+/* valid namespaces with normal indent */ | |
+namespace | |
+{ | |
+{ | |
+ 111111111111; | |
+} | |
+} | |
+namespace /* test */ | |
+{ | |
+11111111111111111; | |
+} | |
+namespace // test | |
+{ | |
+111111111111111111; | |
+} | |
+namespace | |
+{ | |
+111111111111111111; | |
+} | |
+namespace test | |
+{ | |
+111111111111111111; | |
+} | |
+namespace test::cpp17 | |
+{ | |
+111111111111111111; | |
+} | |
+namespace ::incorrectcpp17 | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test::incorrectcpp17:: | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test:incorrectcpp17 | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test:::incorrectcpp17 | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace{ | |
+111111111111111111; | |
+} | |
+namespace test{ | |
+111111111111111111; | |
+} | |
+namespace { | |
+111111111111111111; | |
+} | |
+namespace test { | |
+111111111111111111; | |
+namespace test2 { | |
+22222222222222222; | |
+} | |
+} | |
+ | |
+/* invalid namespaces use block indent */ | |
+namespace test test2 { | |
+ 111111111111111111111; | |
+} | |
+namespace11111111111 { | |
+ 111111111111; | |
+} | |
+namespace() { | |
+ 1111111111111; | |
+} | |
+namespace() | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test test2 | |
+{ | |
+ 1111111111111111111; | |
+} | |
+namespace111111111 | |
+{ | |
+ 111111111111111111; | |
+} | |
+NAMESPACEEND | |
+ | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+var bar = { | |
+ foo: { | |
+ that: this, | |
+ some: ok, | |
+ }, | |
+ "bar":{ | |
+ a : 2, | |
+ b: "123abc", | |
+ x: 4, | |
+ "y": 5 | |
+ } | |
+} | |
+JSEND | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+var foo = [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+]; | |
+JSEND | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+function bar() { | |
+ var foo = [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+JSEND | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+(function($){ | |
+ | |
+ if (cond && | |
+ cond) { | |
+ stmt; | |
+ } | |
+ window.something.left = | |
+ (width - 50 + offset) + "px"; | |
+ var class_name='myclass'; | |
+ | |
+ function private_method() { | |
+ } | |
+ | |
+ var public_method={ | |
+ method: function(options,args){ | |
+ private_method(); | |
+ } | |
+ } | |
+ | |
+ function init(options) { | |
+ | |
+ $(this).data(class_name+'_public',$.extend({},{ | |
+ foo: 'bar', | |
+ bar: 2, | |
+ foobar: [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ], | |
+ callback: function(){ | |
+ return true; | |
+ } | |
+ }, options||{})); | |
+ } | |
+ | |
+ $.fn[class_name]=function() { | |
+ | |
+ var _arguments=arguments; | |
+ return this.each(function(){ | |
+ | |
+ var options=$(this).data(class_name+'_public'); | |
+ if (!options) { | |
+ init.apply(this,_arguments); | |
+ | |
+ } else { | |
+ var method=public_method[_arguments[0]]; | |
+ | |
+ if (typeof(method)!='function') { | |
+ console.log(class_name+' has no method "'+_arguments[0]+'"'); | |
+ return false; | |
+ } | |
+ _arguments[0]=options; | |
+ method.apply(this,_arguments); | |
+ } | |
+ }); | |
+ } | |
+ | |
+})(jQuery); | |
+JSEND | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+function init(options) { | |
+ $(this).data(class_name+'_public',$.extend({},{ | |
+ foo: 'bar', | |
+ bar: 2, | |
+ foobar: [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ], | |
+ callback: function(){ | |
+ return true; | |
+ } | |
+ }, options||{})); | |
+} | |
+JSEND | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+(function($){ | |
+ function init(options) { | |
+ $(this).data(class_name+'_public',$.extend({},{ | |
+ foo: 'bar', | |
+ bar: 2, | |
+ foobar: [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ], | |
+ callback: function(){ | |
+ return true; | |
+ } | |
+ }, options||{})); | |
+ } | |
+})(jQuery); | |
+JSEND | |
+ | |
+ENDTEST | |
+ | |
+JSSTART | |
+// Results of JavaScript indent | |
+// 1 | |
+(function(){ | |
+ var a = [ | |
+ 'a', | |
+ 'b', | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+ ]; | |
+}()) | |
+ | |
+// 2 | |
+(function(){ | |
+ var a = [ | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'a', | |
+ 'b', | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+ ]; | |
+}()) | |
+ | |
+// 3 | |
+(function(){ | |
+ var a = [ | |
+ 0 + | |
+ // comment 1 | |
+ 5 * | |
+ /* comment 2 */ | |
+ 9 * | |
+ 'a', | |
+ 'b', | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+ ]; | |
+}()) | |
+ | |
+// 4 | |
+{ | |
+ var a = [ | |
+ 0, | |
+ 1 | |
+ ]; | |
+ var b; | |
+ var c; | |
+} | |
+ | |
+// 5 | |
+{ | |
+ var a = [ | |
+ [ | |
+ 0 | |
+ ], | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+ | |
+// 6 | |
+{ | |
+ var a = [ | |
+ [ | |
+ 0, | |
+ 1 | |
+ ], | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+ | |
+// 7 | |
+{ | |
+ var a = [ | |
+ // [ | |
+ 0, | |
+ // 1 | |
+ // ], | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+ | |
+// 8 | |
+var x = [ | |
+ (function(){ | |
+ var a, | |
+ b, | |
+ c, | |
+ d, | |
+ e, | |
+ f, | |
+ g, | |
+ h, | |
+ i; | |
+ }) | |
+]; | |
+ | |
+// 9 | |
+var a = [ | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'a', | |
+ 'b', | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+]; | |
+ | |
+// 10 | |
+var a, | |
+ b, | |
+ c, | |
+ d, | |
+ e, | |
+ f, | |
+ g, | |
+ h, | |
+ i; | |
+JSEND | |
+ | |
+ENDTEST | |
diff --git a/src/testdir/test_cindent/test_.txt b/src/testdir/test_cindent/test_.txt | |
new file mode 100644 | |
index 0000000..db394f0 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_.txt | |
@@ -0,0 +1,15 @@ | |
+ | |
+{ | |
+ do | |
+ { | |
+ if () | |
+ { | |
+ if () | |
+ asdf; | |
+ else | |
+ asdf; | |
+ } | |
+ } while (); | |
+ cmd; /* this should go under the } */ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_001.txt b/src/testdir/test_cindent/test_001.txt | |
new file mode 100644 | |
index 0000000..8ae5d8b | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_001.txt | |
@@ -0,0 +1,959 @@ | |
+ | |
+/* start of AUTO matically checked vim: set ts=4 : */ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ else | |
+ } | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) | |
+ cmd; | |
+} | |
+ | |
+{ | |
+ if (test) { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) cmd; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ cmd3; | |
+ } | |
+} | |
+ | |
+ | |
+/* Test for 'cindent' do/while mixed with if/else: */ | |
+ | |
+{ | |
+ do | |
+ if (asdf) | |
+ asdfasd; | |
+ while (cond); | |
+ | |
+ do | |
+ if (asdf) | |
+ while (asdf) | |
+ asdf; | |
+ while (asdf); | |
+} | |
+ | |
+/* Test for 'cindent' with two ) on a continuation line */ | |
+{ | |
+ if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d | |
+ aal;sdkjf ( ;asldfkja;sldfk | |
+ al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) | |
+ line up here; | |
+} | |
+ | |
+ | |
+/* C++ tests: */ | |
+ | |
+// foo() these three lines should remain in column 0 | |
+// { | |
+// } | |
+ | |
+/* Test for continuation and unterminated lines: */ | |
+{ | |
+ i = 99 + 14325 + | |
+ 21345 + | |
+ 21345 + | |
+ 21345 + ( 21345 + | |
+ 21345) + | |
+ 2345 + | |
+ 1234; | |
+ c = 1; | |
+} | |
+ | |
+/* | |
+ testje for indent with empty line | |
+ | |
+ here */ | |
+ | |
+{ | |
+ if (testing && | |
+ not a joke || | |
+ line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ )line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ line up here)) | |
+ hay; | |
+} | |
+ | |
+ | |
+{ | |
+ switch (c) | |
+ { | |
+ case xx: | |
+ do | |
+ if (asdf) | |
+ do | |
+ asdfasdf; | |
+ while (asdf); | |
+ else | |
+ asdfasdf; | |
+ while (cond); | |
+ case yy: | |
+ case xx: | |
+ case zz: | |
+ testing; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (cond) { | |
+ foo; | |
+ } | |
+ else | |
+ { | |
+ bar; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf | |
+ alsdkfj (asldk;fj | |
+ awith cino=(0 ;lf this one goes to below the paren with == | |
+ ;laksjfd ;lsakdjf ;alskdf asd) | |
+ asdfasdf;))) | |
+ asdfasdf; | |
+} | |
+ | |
+ int | |
+func(a, b) | |
+ int a; | |
+ int c; | |
+{ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3) | |
+ ) | |
+} | |
+ | |
+{ | |
+ while (asd) | |
+ { | |
+ if (asdf) | |
+ if (test) | |
+ if (that) | |
+ { | |
+ if (asdf) | |
+ do | |
+ cdasd; | |
+ while (as | |
+ df); | |
+ } | |
+ else | |
+ if (asdf) | |
+ asdf; | |
+ else | |
+ asdf; | |
+ asdf; | |
+ } | |
+} | |
+ | |
+{ | |
+ s = "/*"; b = ';' | |
+ s = "/*"; b = ';'; | |
+ a = b; | |
+} | |
+ | |
+{ | |
+ switch (a) | |
+ { | |
+ case a: | |
+ switch (t) | |
+ { | |
+ case 1: | |
+ cmd; | |
+ break; | |
+ case 2: | |
+ cmd; | |
+ break; | |
+ } | |
+ cmd; | |
+ break; | |
+ case b: | |
+ { | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ case c: { | |
+ int i; | |
+ cmd; | |
+ } | |
+ case d: if (cond && | |
+ test) { /* this line doesn't work right */ | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && | |
+ (bp_to->b_p_initialized || | |
+ (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
+ return; | |
+label : | |
+ asdf = asdf ? | |
+ asdf : asdf; | |
+ asdf = asdf ? | |
+ asdf: asdf; | |
+} | |
+ | |
+/* Special Comments : This function has the added complexity (compared */ | |
+/* : to addtolist) of having to check for a detail */ | |
+/* : texture and add that to the list first. */ | |
+ | |
+char *(array[100]) = { | |
+ "testje", | |
+ "foo", | |
+ "bar", | |
+} | |
+ | |
+enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+typedef enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+public static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+static private enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+{ | |
+ int a, | |
+ b; | |
+} | |
+ | |
+{ | |
+ struct Type | |
+ { | |
+ int i; | |
+ char *str; | |
+ } var[] = | |
+ { | |
+ 0, "zero", | |
+ 1, "one", | |
+ 2, "two", | |
+ 3, "three" | |
+ }; | |
+ | |
+ float matrix[3][3] = | |
+ { | |
+ { | |
+ 0, | |
+ 1, | |
+ 2 | |
+ }, | |
+ { | |
+ 3, | |
+ 4, | |
+ 5 | |
+ }, | |
+ { | |
+ 6, | |
+ 7, | |
+ 8 | |
+ } | |
+ }; | |
+} | |
+ | |
+{ | |
+ /* blah ( blah */ | |
+ /* where does this go? */ | |
+ | |
+ /* blah ( blah */ | |
+ cmd; | |
+ | |
+ func(arg1, | |
+ /* comment */ | |
+ arg2); | |
+ a; | |
+ { | |
+ b; | |
+ { | |
+ c; /* Hey, NOW it indents?! */ | |
+ } | |
+ } | |
+ | |
+ { | |
+ func(arg1, | |
+ arg2, | |
+ arg3); | |
+ /* Hey, what am I doing here? Is this coz of the ","? */ | |
+ } | |
+} | |
+ | |
+main () | |
+{ | |
+ if (cond) | |
+ { | |
+ a = b; | |
+ } | |
+ if (cond) { | |
+ a = c; | |
+ } | |
+ if (cond) | |
+ a = d; | |
+ return; | |
+} | |
+ | |
+{ | |
+ case 2: if (asdf && | |
+ asdfasdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 3: if (asdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 4: x = 1; | |
+ y = 2; | |
+ | |
+label: if (asdf) | |
+ here; | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ { | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) { | |
+ there; | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ there; | |
+} | |
+ | |
+{ | |
+ /* | |
+ hello with ":set comments= cino=c5" | |
+ */ | |
+ | |
+ /* | |
+ hello with ":set comments= cino=" | |
+ */ | |
+} | |
+ | |
+ | |
+{ | |
+ if (a < b) { | |
+ a = a + 1; | |
+ } else | |
+ a = a + 2; | |
+ | |
+ if (a) | |
+ do { | |
+ testing; | |
+ } while (asdfasdf); | |
+ a = b + 1; | |
+ asdfasdf | |
+} | |
+ | |
+{ | |
+ for ( int i = 0; | |
+ i < 10; i++ ) | |
+ { | |
+ } | |
+ i = 0; | |
+} | |
+ | |
+class bob | |
+{ | |
+ int foo() {return 1;} | |
+ int bar; | |
+} | |
+ | |
+main() | |
+{ | |
+ while(1) | |
+ if (foo) | |
+ { | |
+ bar; | |
+ } | |
+ else { | |
+ asdf; | |
+ } | |
+ misplacedline; | |
+} | |
+ | |
+{ | |
+ if (clipboard.state == SELECT_DONE | |
+ && ((row == clipboard.start.lnum | |
+ && col >= clipboard.start.col) | |
+ || row > clipboard.start.lnum)) | |
+} | |
+ | |
+{ | |
+ if (1) {i += 4;} | |
+ where_am_i; | |
+ return 0; | |
+} | |
+ | |
+{ | |
+ { | |
+ } // sdf(asdf | |
+ if (asdf) | |
+ asd; | |
+} | |
+ | |
+{ | |
+label1: | |
+label2: | |
+} | |
+ | |
+{ | |
+ int fooRet = foo(pBar1, false /*fKB*/, | |
+ true /*fPTB*/, 3 /*nT*/, false /*fDF*/); | |
+ f() { | |
+ for ( i = 0; | |
+ i < m; | |
+ /* c */ i++ ) { | |
+ a = b; | |
+ } | |
+ } | |
+} | |
+ | |
+{ | |
+ f1(/*comment*/); | |
+ f2(); | |
+} | |
+ | |
+{ | |
+ do { | |
+ if (foo) { | |
+ } else | |
+ ; | |
+ } while (foo); | |
+ foo(); // was wrong | |
+} | |
+ | |
+int x; // no extra indent because of the ; | |
+void func() | |
+{ | |
+} | |
+ | |
+char *tab[] = {"aaa", | |
+ "};", /* }; */ NULL} | |
+ int indented; | |
+{} | |
+ | |
+char *a[] = {"aaa", "bbb", | |
+ "ccc", NULL}; | |
+// here | |
+ | |
+char *tab[] = {"aaa", | |
+ "xx", /* xx */}; /* asdf */ | |
+int not_indented; | |
+ | |
+{ | |
+ do { | |
+ switch (bla) | |
+ { | |
+ case 1: if (foo) | |
+ bar; | |
+ } | |
+ } while (boo); | |
+ wrong; | |
+} | |
+ | |
+int foo, | |
+ bar; | |
+int foo; | |
+ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+char * xx = "asdf\ | |
+ foo\ | |
+ bor"; | |
+int x; | |
+ | |
+char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ | |
+void f() | |
+{ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ { | |
+ int i; | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ } | |
+#endif | |
+} | |
+#endif | |
+ | |
+int y; // comment | |
+// comment | |
+ | |
+// comment | |
+ | |
+{ | |
+ Constructor(int a, | |
+ int b ) : BaseClass(a) | |
+ { | |
+ } | |
+} | |
+ | |
+void foo() | |
+{ | |
+ char one, | |
+ two; | |
+ struct bla piet, | |
+ jan; | |
+ enum foo kees, | |
+ jannie; | |
+ static unsigned sdf, | |
+ krap; | |
+ unsigned int piet, | |
+ jan; | |
+ int | |
+ kees, | |
+ jan; | |
+} | |
+ | |
+{ | |
+ t(int f, | |
+ int d); // ) | |
+ d(); | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b), | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) : | |
+ BaseClass(a) | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) /*x*/ : /*x*/ BaseClass(a), | |
+ member(b) | |
+{ | |
+} | |
+ | |
+A::A(int a, int b) | |
+ : aa(a), | |
+ bb(b), | |
+ cc(c) | |
+{ | |
+} | |
+ | |
+class CAbc : | |
+ public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+ int Test() { return FALSE; } | |
+ int Test1() { return TRUE; } | |
+ | |
+ CAbc(int a, int b ) : | |
+ BaseClass(a) | |
+ { | |
+ switch(xxx) | |
+ { | |
+ case abc: | |
+ asdf(); | |
+ break; | |
+ | |
+ case 999: | |
+ baer(); | |
+ break; | |
+ } | |
+ } | |
+ | |
+ public: // <-- this was incoreectly indented before!! | |
+ void testfall(); | |
+ protected: | |
+ void testfall(); | |
+}; | |
+ | |
+class CAbc : public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { | |
+ 123, | |
+ 456 | |
+ }, | |
+ { | |
+ 123, | |
+ 456 | |
+ } | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { 123, 456 }, | |
+ { 123, 456 } | |
+}; | |
+ | |
+void asdf() /* ind_maxparen may cause trouble here */ | |
+{ | |
+ if ((0 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1)) break; | |
+} | |
+ | |
+foo() | |
+{ | |
+ a = cond ? foo() : asdf | |
+ + asdf; | |
+ | |
+ a = cond ? | |
+ foo() : asdf | |
+ + asdf; | |
+} | |
+ | |
+int main(void) | |
+{ | |
+ if (a) | |
+ if (b) | |
+ 2; | |
+ else 3; | |
+ next_line_of_code(); | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, | |
+ int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b) | |
+{ | |
+} | |
+int main () | |
+{ | |
+ if (lala) | |
+ do | |
+ ++(*lolo); | |
+ while (lili | |
+ && lele); | |
+ lulu; | |
+} | |
+ | |
+int main () | |
+{ | |
+ switch (c) | |
+ { | |
+ case 'c': if (cond) | |
+ { | |
+ } | |
+ } | |
+} | |
+ | |
+main() | |
+{ | |
+ (void) MyFancyFuasdfadsfnction( | |
+ argument); | |
+} | |
+ | |
+main() | |
+{ | |
+ char foo[] = "/*"; | |
+ /* as | |
+ df */ | |
+ hello | |
+} | |
+ | |
+/* valid namespaces with normal indent */ | |
+namespace | |
+{ | |
+ { | |
+ 111111111111; | |
+ } | |
+} | |
+namespace /* test */ | |
+{ | |
+ 11111111111111111; | |
+} | |
+namespace // test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace{ | |
+ 111111111111111111; | |
+} | |
+namespace test{ | |
+ 111111111111111111; | |
+} | |
+namespace { | |
+ 111111111111111111; | |
+} | |
+namespace test { | |
+ 111111111111111111; | |
+ namespace test2 { | |
+ 22222222222222222; | |
+ } | |
+} | |
+ | |
+/* invalid namespaces use block indent */ | |
+namespace test test2 { | |
+ 111111111111111111111; | |
+} | |
+namespace11111111111 { | |
+ 111111111111; | |
+} | |
+namespace() { | |
+ 1111111111111; | |
+} | |
+namespace() | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test test2 | |
+{ | |
+ 1111111111111111111; | |
+} | |
+namespace111111111 | |
+{ | |
+ 111111111111111111; | |
+} | |
+ | |
+void getstring() { | |
+ /* Raw strings */ | |
+ const char* s = R"( | |
+ test { | |
+ # comment | |
+ field: 123 | |
+ } | |
+ )"; | |
+} | |
+ | |
+void getstring() { | |
+ const char* s = R"foo( | |
+ test { | |
+ # comment | |
+ field: 123 | |
+ } | |
+ )foo"; | |
+} | |
+ | |
+{ | |
+ int a[4] = { | |
+ [0] = 0, | |
+ [1] = 1, | |
+ [2] = 2, | |
+ [3] = 3, | |
+ }; | |
+} | |
+ | |
+{ | |
+ a = b[2] | |
+ + 3; | |
+} | |
+ | |
+{ | |
+ if (1) | |
+ /* aaaaa | |
+ * bbbbb | |
+ */ | |
+ a = 1; | |
+} | |
+ | |
+void func() | |
+{ | |
+ switch (foo) | |
+ { | |
+ case (bar): | |
+ if (baz()) | |
+ quux(); | |
+ break; | |
+ case (shmoo): | |
+ if (!bar) | |
+ { | |
+ } | |
+ case (foo1): | |
+ switch (bar) | |
+ { | |
+ case baz: | |
+ baz_f(); | |
+ break; | |
+ } | |
+ break; | |
+ default: | |
+ baz(); | |
+ baz(); | |
+ break; | |
+ } | |
+} | |
+ | |
+/* end of AUTO */ | |
+ | |
diff --git a/src/testdir/test_cindent/test_001_ng.txt b/src/testdir/test_cindent/test_001_ng.txt | |
new file mode 100644 | |
index 0000000..ad16a88 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_001_ng.txt | |
@@ -0,0 +1,959 @@ | |
+ | |
+/* start of AUTO matically checked vim: set ts=4 : */ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ else | |
+ } | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) | |
+ cmd; | |
+} | |
+ | |
+{ | |
+ if (test) { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) cmd; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ cmd3; | |
+ } | |
+} | |
+ | |
+ | |
+/* Test for 'cindent' do/while mixed with if/else: */ | |
+ | |
+{ | |
+ do | |
+ if (asdf) | |
+ asdfasd; | |
+ while (cond); | |
+ | |
+ do | |
+ if (asdf) | |
+ while (asdf) | |
+ asdf; | |
+ while (asdf); | |
+} | |
+ | |
+/* Test for 'cindent' with two ) on a continuation line */ | |
+{ | |
+ if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d | |
+ aal;sdkjf ( ;asldfkja;sldfk | |
+ al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) | |
+ line up here; | |
+} | |
+ | |
+ | |
+/* C++ tests: */ | |
+ | |
+// foo() these three lines should remain in column 0 | |
+// { | |
+// } | |
+ | |
+/* Test for continuation and unterminated lines: */ | |
+{ | |
+ i = 99 + 14325 + | |
+ 21345 + | |
+ 21345 + | |
+ 21345 + ( 21345 + | |
+ 21345) + | |
+ 2345 + | |
+ 1234; | |
+ c = 1; | |
+} | |
+ | |
+/* | |
+ testje for indent with empty line | |
+ | |
+ here */ | |
+ | |
+{ | |
+ if (testing && | |
+ not a joke || | |
+ line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ )line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ line up here)) | |
+ hay; | |
+} | |
+ | |
+ | |
+{ | |
+ switch (c) | |
+ { | |
+ case xx: | |
+ do | |
+ if (asdf) | |
+ do | |
+ asdfasdf; | |
+ while (asdf); | |
+ else | |
+ asdfasdf; | |
+ while (cond); | |
+ case yy: | |
+ case xx: | |
+ case zz: | |
+ testing; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (cond) { | |
+ foo; | |
+ } | |
+ else | |
+ { | |
+ bar; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf | |
+ alsdkfj (asldk;fj | |
+ awith cino=(0 ;lf this one goes to below the paren with == | |
+ ;laksjfd ;lsakdjf ;alskdf asd) | |
+ asdfasdf;))) | |
+ asdfasdf; | |
+} | |
+ | |
+ int | |
+func(a, b) | |
+ int a; | |
+ int c; | |
+{ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3) | |
+ ) | |
+} | |
+ | |
+{ | |
+ while (asd) | |
+ { | |
+ if (asdf) | |
+ if (test) | |
+ if (that) | |
+ { | |
+ if (asdf) | |
+ do | |
+ cdasd; | |
+ while (as | |
+ df); | |
+ } | |
+ else | |
+ if (asdf) | |
+ asdf; | |
+ else | |
+ asdf; | |
+ asdf; | |
+ } | |
+} | |
+ | |
+{ | |
+ s = "/*"; b = ';' | |
+ s = "/*"; b = ';'; | |
+ a = b; | |
+} | |
+ | |
+{ | |
+ switch (a) | |
+ { | |
+ case a: | |
+ switch (t) | |
+ { | |
+ case 1: | |
+ cmd; | |
+ break; | |
+ case 2: | |
+ cmd; | |
+ break; | |
+ } | |
+ cmd; | |
+ break; | |
+ case b: | |
+ { | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ case c: { | |
+ int i; | |
+ cmd; | |
+ } | |
+ case d: if (cond && | |
+ test) { /* this line doesn't work right */ | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && | |
+ (bp_to->b_p_initialized || | |
+ (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
+ return; | |
+label : | |
+ asdf = asdf ? | |
+ asdf : asdf; | |
+ asdf = asdf ? | |
+ asdf: asdf; | |
+} | |
+ | |
+/* Special Comments : This function has the added complexity (compared */ | |
+/* : to addtolist) of having to check for a detail */ | |
+/* : texture and add that to the list first. */ | |
+ | |
+char *(array[100]) = { | |
+ "testje", | |
+ "foo", | |
+ "bar", | |
+} | |
+ | |
+enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+typedef enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+public static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+static private enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+{ | |
+ int a, | |
+ b; | |
+} | |
+ | |
+{ | |
+ struct Type | |
+ { | |
+ int i; | |
+ char *str; | |
+ } var[] = | |
+ { | |
+ 0, "zero", | |
+ 1, "one", | |
+ 2, "two", | |
+ 3, "three" | |
+ }; | |
+ | |
+ float matrix[3][3] = | |
+ { | |
+ { | |
+ 0, | |
+ 1, | |
+ 2 | |
+ }, | |
+ { | |
+ 3, | |
+ 4, | |
+ 5 | |
+ }, | |
+ { | |
+ 6, | |
+ 7, | |
+ 8 | |
+ } | |
+ }; | |
+} | |
+ | |
+{ | |
+ /* blah ( blah */ | |
+ /* where does this go? */ | |
+ | |
+ /* blah ( blah */ | |
+ cmd; | |
+ | |
+ func(arg1, | |
+ /* comment */ | |
+ arg2); | |
+ a; | |
+ { | |
+ b; | |
+ { | |
+ c; /* Hey, NOW it indents?! */ | |
+ } | |
+ } | |
+ | |
+ { | |
+ func(arg1, | |
+ arg2, | |
+ arg3); | |
+ /* Hey, what am I doing here? Is this coz of the ","? */ | |
+ } | |
+} | |
+ | |
+main () | |
+{ | |
+ if (cond) | |
+ { | |
+ a = b; | |
+ } | |
+ if (cond) { | |
+ a = c; | |
+ } | |
+ if (cond) | |
+ a = d; | |
+ return; | |
+} | |
+ | |
+{ | |
+ case 2: if (asdf && | |
+ asdfasdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 3: if (asdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 4: x = 1; | |
+ y = 2; | |
+ | |
+label: if (asdf) | |
+ here; | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ { | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) { | |
+ there; | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ there; | |
+} | |
+ | |
+{ | |
+ /* | |
+ hello with ":set comments= cino=c5" | |
+ */ | |
+ | |
+ /* | |
+ hello with ":set comments= cino=" | |
+ */ | |
+} | |
+ | |
+ | |
+{ | |
+ if (a < b) { | |
+ a = a + 1; | |
+ } else | |
+ a = a + 2; | |
+ | |
+ if (a) | |
+ do { | |
+ testing; | |
+ } while (asdfasdf); | |
+ a = b + 1; | |
+ asdfasdf | |
+} | |
+ | |
+{ | |
+ for ( int i = 0; | |
+ i < 10; i++ ) | |
+ { | |
+ } | |
+ i = 0; | |
+} | |
+ | |
+class bob | |
+{ | |
+ int foo() {return 1;} | |
+ int bar; | |
+} | |
+ | |
+main() | |
+{ | |
+ while(1) | |
+ if (foo) | |
+ { | |
+ bar; | |
+ } | |
+ else { | |
+ asdf; | |
+ } | |
+ misplacedline; | |
+} | |
+ | |
+{ | |
+ if (clipboard.state == SELECT_DONE | |
+ && ((row == clipboard.start.lnum | |
+ && col >= clipboard.start.col) | |
+ || row > clipboard.start.lnum)) | |
+} | |
+ | |
+{ | |
+ if (1) {i += 4;} | |
+ where_am_i; | |
+ return 0; | |
+} | |
+ | |
+{ | |
+ { | |
+ } // sdf(asdf | |
+ if (asdf) | |
+ asd; | |
+} | |
+ | |
+{ | |
+label1: | |
+label2: | |
+} | |
+ | |
+{ | |
+ int fooRet = foo(pBar1, false /*fKB*/, | |
+ true /*fPTB*/, 3 /*nT*/, false /*fDF*/); | |
+ f() { | |
+ for ( i = 0; | |
+ i < m; | |
+ /* c */ i++ ) { | |
+ a = b; | |
+ } | |
+ } | |
+} | |
+ | |
+{ | |
+ f1(/*comment*/); | |
+ f2(); | |
+} | |
+ | |
+{ | |
+ do { | |
+ if (foo) { | |
+ } else | |
+ ; | |
+ } while (foo); | |
+ foo(); // was wrong | |
+} | |
+ | |
+int x; // no extra indent because of the ; | |
+void func() | |
+{ | |
+} | |
+ | |
+char *tab[] = {"aaa", | |
+ "};", /* }; */ NULL} | |
+ int indented; | |
+{} | |
+ | |
+char *a[] = {"aaa", "bbb", | |
+ "ccc", NULL}; | |
+// here | |
+ | |
+char *tab[] = {"aaa", | |
+ "xx", /* xx */}; /* asdf */ | |
+int not_indented; | |
+ | |
+{ | |
+ do { | |
+ switch (bla) | |
+ { | |
+ case 1: if (foo) | |
+ bar; | |
+ } | |
+ } while (boo); | |
+ wrong; | |
+} | |
+ | |
+int foo, | |
+ bar; | |
+int foo; | |
+ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+char * xx = "asdf\ | |
+ foo\ | |
+ bor"; | |
+int x; | |
+ | |
+char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ | |
+void f() | |
+{ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ { | |
+ int i; | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ } | |
+#endif | |
+} | |
+#endif | |
+ | |
+int y; // comment | |
+// comment | |
+ | |
+// comment | |
+ | |
+{ | |
+ Constructor(int a, | |
+ int b ) : BaseClass(a) | |
+ { | |
+ } | |
+} | |
+ | |
+void foo() | |
+{ | |
+ char one, | |
+ two; | |
+ struct bla piet, | |
+ jan; | |
+ enum foo kees, | |
+ jannie; | |
+ static unsigned sdf, | |
+ krap; | |
+ unsigned int piet, | |
+ jan; | |
+ int | |
+ kees, | |
+ jan; | |
+} | |
+ | |
+{ | |
+ t(int f, | |
+ int d); // ) | |
+ d(); | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b), | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) : | |
+ BaseClass(a) | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) /*x*/ : /*x*/ BaseClass(a), | |
+ member(b) | |
+{ | |
+} | |
+ | |
+A::A(int a, int b) | |
+ : aa(a), | |
+ bb(b), | |
+ cc(c) | |
+{ | |
+} | |
+ | |
+class CAbc : | |
+ public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+ int Test() { return FALSE; } | |
+ int Test1() { return TRUE; } | |
+ | |
+ CAbc(int a, int b ) : | |
+ BaseClass(a) | |
+ { | |
+ switch(xxx) | |
+ { | |
+ case abc: | |
+ asdf(); | |
+ break; | |
+ | |
+ case 999: | |
+ baer(); | |
+ break; | |
+ } | |
+ } | |
+ | |
+ public: // <-- this was incoreectly indented before!! | |
+ void testfall(); | |
+ protected: | |
+ void testfall(); | |
+}; | |
+ | |
+class CAbc : public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { | |
+ 123, | |
+ 456 | |
+ }, | |
+ { | |
+ 123, | |
+ 456 | |
+ } | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { 123, 456 }, | |
+ { 123, 456 } | |
+}; | |
+ | |
+void asdf() /* ind_maxparen may cause trouble here */ | |
+{ | |
+ if ((0 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1)) break; | |
+} | |
+ | |
+foo() | |
+{ | |
+ a = cond ? foo() : asdf | |
+ + asdf; | |
+ | |
+ a = cond ? | |
+ foo() : asdf | |
+ + asdf; | |
+} | |
+ | |
+int main(void) | |
+{ | |
+ if (a) | |
+ if (b) | |
+ 2; | |
+ else 3; | |
+ next_line_of_code(); | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, | |
+ int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b) | |
+{ | |
+} | |
+int main () | |
+{ | |
+ if (lala) | |
+ do | |
+ ++(*lolo); | |
+ while (lili | |
+ && lele); | |
+ lulu; | |
+} | |
+ | |
+int main () | |
+{ | |
+ switch (c) | |
+ { | |
+ case 'c': if (cond) | |
+ { | |
+ } | |
+ } | |
+} | |
+ | |
+main() | |
+{ | |
+ (void) MyFancyFuasdfadsfnction( | |
+ argument); | |
+} | |
+ | |
+main() | |
+{ | |
+ char foo[] = "/*"; | |
+ /* as | |
+ df */ | |
+ hello | |
+} | |
+ | |
+/* valid namespaces with normal indent */ | |
+namespace | |
+{ | |
+ { | |
+ 111111111111; | |
+ } | |
+} | |
+namespace /* test */ | |
+{ | |
+ 11111111111111111; | |
+} | |
+namespace // test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace{ | |
+ 111111111111111111; | |
+} | |
+namespace test{ | |
+ 111111111111111111; | |
+} | |
+namespace { | |
+ 111111111111111111; | |
+} | |
+namespace test { | |
+ 111111111111111111; | |
+ namespace test2 { | |
+ 22222222222222222; | |
+ } | |
+} | |
+ | |
+/* invalid namespaces use block indent */ | |
+namespace test test2 { | |
+ 111111111111111111111; | |
+} | |
+namespace11111111111 { | |
+ 111111111111; | |
+} | |
+namespace() { | |
+ 1111111111111; | |
+} | |
+namespace() | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test test2 | |
+{ | |
+ 1111111111111111111; | |
+} | |
+namespace111111111 | |
+{ | |
+ 111111111111111111; | |
+} | |
+ | |
+void getstring() { | |
+ /* Raw strings */ | |
+ const char* s = R"( | |
+test { | |
+# comment | |
+field: 123 | |
+} | |
+)"; | |
+ } | |
+ | |
+void getstring() { | |
+ const char* s = R"foo( | |
+test { | |
+# comment | |
+field: 123 | |
+} | |
+)foo"; | |
+ } | |
+ | |
+{ | |
+ int a[4] = { | |
+ [0] = 0, | |
+ [1] = 1, | |
+ [2] = 2, | |
+ [3] = 3, | |
+ }; | |
+} | |
+ | |
+{ | |
+ a = b[2] | |
+ + 3; | |
+} | |
+ | |
+{ | |
+ if (1) | |
+ /* aaaaa | |
+ * bbbbb | |
+ */ | |
+ a = 1; | |
+} | |
+ | |
+void func() | |
+{ | |
+ switch (foo) | |
+ { | |
+ case (bar): | |
+ if (baz()) | |
+ quux(); | |
+ break; | |
+ case (shmoo): | |
+ if (!bar) | |
+ { | |
+ } | |
+ case (foo1): | |
+ switch (bar) | |
+ { | |
+ case baz: | |
+ baz_f(); | |
+ break; | |
+ } | |
+ break; | |
+ default: | |
+ baz(); | |
+ baz(); | |
+ break; | |
+ } | |
+} | |
+ | |
+/* end of AUTO */ | |
+ | |
diff --git a/src/testdir/test_cindent/test_002.txt b/src/testdir/test_cindent/test_002.txt | |
new file mode 100644 | |
index 0000000..74bd969 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_002.txt | |
@@ -0,0 +1,13 @@ | |
+ | |
+{ | |
+ | |
+/* this is | |
+ * a real serious | |
+ * about life, the | |
+ * universe, and the | |
+ * rest important big | |
+ * comment | |
+ */ | |
+ /* insert " about life, the universe, and the rest" after "serious" */ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_003.txt b/src/testdir/test_cindent/test_003.txt | |
new file mode 100644 | |
index 0000000..be99a75 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_003.txt | |
@@ -0,0 +1,21 @@ | |
+ | |
+{ | |
+ /* | |
+ * Testing for comments, without 'cin' set | |
+ */ | |
+about life | |
+ | |
+/* | |
+* what happens here? | |
+*/ | |
+there | |
+ | |
+ /* | |
+ the end of the comment, try inserting a line below */ | |
+line | |
+ | |
+ /* how about | |
+hello | |
+ this one */ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_004.txt b/src/testdir/test_cindent/test_004.txt | |
new file mode 100644 | |
index 0000000..d2093e5 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_004.txt | |
@@ -0,0 +1,7 @@ | |
+ | |
+{ | |
+ var = this + that + vec[0] * vec[0] | |
+ + vec[1] * vec[1] | |
+ + vec2[2] * vec[2]; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_005.txt b/src/testdir/test_cindent/test_005.txt | |
new file mode 100644 | |
index 0000000..d06fa63 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_005.txt | |
@@ -0,0 +1,16 @@ | |
+ | |
+{ | |
+ asdf asdflkajds f; | |
+ if (tes & ting) { | |
+ asdf asdf asdf ; | |
+ asdfa sdf asdf; | |
+ } | |
+ testing1; | |
+ if (tes & ting) | |
+ { | |
+ asdf asdf asdf ; | |
+ asdfa sdf asdf; | |
+ } | |
+ testing2; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_006.txt b/src/testdir/test_cindent/test_006.txt | |
new file mode 100644 | |
index 0000000..f42172e | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_006.txt | |
@@ -0,0 +1,23 @@ | |
+ | |
+main ( int first_par, /* | |
+ * Comment for | |
+ * first par | |
+ */ | |
+ int second_par /* | |
+ * Comment for | |
+ * second par | |
+ */ | |
+ ) | |
+{ | |
+ func( first_par, /* | |
+ * Comment for | |
+ * first par | |
+ */ | |
+ second_par /* | |
+ * Comment for | |
+ * second par | |
+ */ | |
+ ); | |
+ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_007.txt b/src/testdir/test_cindent/test_007.txt | |
new file mode 100644 | |
index 0000000..9a8d59b | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_007.txt | |
@@ -0,0 +1,12 @@ | |
+ | |
+main(void) | |
+{ | |
+ /* Make sure that cino=X0s is not parsed like cino=Xs. */ | |
+ if (cond) | |
+ foo(); | |
+ else | |
+ { | |
+ bar(); | |
+ } | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_008.txt b/src/testdir/test_cindent/test_008.txt | |
new file mode 100644 | |
index 0000000..db394f0 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_008.txt | |
@@ -0,0 +1,15 @@ | |
+ | |
+{ | |
+ do | |
+ { | |
+ if () | |
+ { | |
+ if () | |
+ asdf; | |
+ else | |
+ asdf; | |
+ } | |
+ } while (); | |
+ cmd; /* this should go under the } */ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_009.txt b/src/testdir/test_cindent/test_009.txt | |
new file mode 100644 | |
index 0000000..a092dc7 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_009.txt | |
@@ -0,0 +1,13 @@ | |
+ | |
+void f() | |
+{ | |
+ if ( k() ) { | |
+ l(); | |
+ | |
+ } else { /* Start (two words) end */ | |
+ m(); | |
+ } | |
+ | |
+ n(); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_010.txt b/src/testdir/test_cindent/test_010.txt | |
new file mode 100644 | |
index 0000000..7210c65 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_010.txt | |
@@ -0,0 +1,12 @@ | |
+ | |
+void f() | |
+ { | |
+ if ( k() ) | |
+ { | |
+ l(); | |
+ } else { /* Start (two words) end */ | |
+ m(); | |
+ } | |
+ n(); /* should be under the if () */ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_011.txt b/src/testdir/test_cindent/test_011.txt | |
new file mode 100644 | |
index 0000000..ec85018 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_011.txt | |
@@ -0,0 +1,34 @@ | |
+ | |
+void bar(void) | |
+ { | |
+ static array[2][2] = | |
+ { | |
+ { 1, 2 }, | |
+ { 3, 4 }, | |
+ } | |
+ | |
+ while (a) | |
+ { | |
+ foo(&a); | |
+ } | |
+ | |
+ { | |
+ int a; | |
+ { | |
+ a = a + 1; | |
+ } | |
+ } | |
+ b = a; | |
+ } | |
+ | |
+void func(void) | |
+ { | |
+ a = 1; | |
+ { | |
+ b = 2; | |
+ } | |
+ c = 3; | |
+ d = 4; | |
+ } | |
+/* foo */ | |
+ | |
diff --git a/src/testdir/test_cindent/test_012.txt b/src/testdir/test_cindent/test_012.txt | |
new file mode 100644 | |
index 0000000..35120b7 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_012.txt | |
@@ -0,0 +1,12 @@ | |
+ | |
+a() | |
+{ | |
+ do { | |
+ a = a + | |
+ a; | |
+ } while ( a ); /* add text under this line */ | |
+ here | |
+ if ( a ) | |
+ a; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_013.txt b/src/testdir/test_cindent/test_013.txt | |
new file mode 100644 | |
index 0000000..611892c | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_013.txt | |
@@ -0,0 +1,14 @@ | |
+ | |
+a() | |
+{ | |
+label1: | |
+ /* hmm */ | |
+ // comment | |
+label2: b(); | |
+label3 /* post */: | |
+/* pre */ label4: | |
+ f(/*com*/); | |
+ if (/*com*/) | |
+ cmd(); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_014.txt b/src/testdir/test_cindent/test_014.txt | |
new file mode 100644 | |
index 0000000..e363002 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_014.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+/* | |
+ * A simple comment | |
+ */ | |
+ | |
+/* | |
+** A different comment | |
+*/ | |
+ | |
diff --git a/src/testdir/test_cindent/test_015.txt b/src/testdir/test_cindent/test_015.txt | |
new file mode 100644 | |
index 0000000..ec3f008 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_015.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+void f() | |
+{ | |
+ | |
+ /********* | |
+ A comment. | |
+ *********/ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_016.txt b/src/testdir/test_cindent/test_016.txt | |
new file mode 100644 | |
index 0000000..2ec7db2 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_016.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+void f() | |
+{ | |
+ | |
+ /********* | |
+ A comment. | |
+ *********/ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_017.txt b/src/testdir/test_cindent/test_017.txt | |
new file mode 100644 | |
index 0000000..1e4cd36 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_017.txt | |
@@ -0,0 +1,10 @@ | |
+ | |
+void f() | |
+{ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_018.txt b/src/testdir/test_cindent/test_018.txt | |
new file mode 100644 | |
index 0000000..1e4cd36 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_018.txt | |
@@ -0,0 +1,10 @@ | |
+ | |
+void f() | |
+{ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_019.txt b/src/testdir/test_cindent/test_019.txt | |
new file mode 100644 | |
index 0000000..25d509d | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_019.txt | |
@@ -0,0 +1,10 @@ | |
+ | |
+void f() | |
+{ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_020.txt b/src/testdir/test_cindent/test_020.txt | |
new file mode 100644 | |
index 0000000..f4fb3fd | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_020.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+void f() | |
+{ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_021.txt b/src/testdir/test_cindent/test_021.txt | |
new file mode 100644 | |
index 0000000..20eafbe | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_021.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+void f() | |
+{ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_022.txt b/src/testdir/test_cindent/test_022.txt | |
new file mode 100644 | |
index 0000000..e600c43 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_022.txt | |
@@ -0,0 +1,13 @@ | |
+ | |
+void f() | |
+{ | |
+ c = c1 && ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+ if ( | |
+ c1 && c2 | |
+ ) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_023.txt b/src/testdir/test_cindent/test_023.txt | |
new file mode 100644 | |
index 0000000..73e62ef | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_023.txt | |
@@ -0,0 +1,13 @@ | |
+ | |
+void f() | |
+{ | |
+ c = c1 && ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+ if ( | |
+ c1 && c2 | |
+ ) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_024.txt b/src/testdir/test_cindent/test_024.txt | |
new file mode 100644 | |
index 0000000..0a090fb | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_024.txt | |
@@ -0,0 +1,14 @@ | |
+ | |
+void f() | |
+{ | |
+ switch (x) | |
+ { | |
+ case 1: | |
+ a = b; | |
+ break; | |
+ default: | |
+ a = 0; | |
+ break; | |
+ } | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_025.txt b/src/testdir/test_cindent/test_025.txt | |
new file mode 100644 | |
index 0000000..bf01922 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_025.txt | |
@@ -0,0 +1,15 @@ | |
+ | |
+void f() | |
+{ | |
+ invokeme( | |
+ argu, | |
+ ment); | |
+ invokeme( | |
+ argu, | |
+ ment | |
+ ); | |
+ invokeme(argu, | |
+ ment | |
+ ); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_026.txt b/src/testdir/test_cindent/test_026.txt | |
new file mode 100644 | |
index 0000000..8ee313d | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_026.txt | |
@@ -0,0 +1,8 @@ | |
+ | |
+void f() | |
+{ | |
+ statement; | |
+ // comment 1 | |
+ // comment 2 | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_027.txt b/src/testdir/test_cindent/test_027.txt | |
new file mode 100644 | |
index 0000000..a00a82f | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_027.txt | |
@@ -0,0 +1,8 @@ | |
+ | |
+void f() | |
+{ | |
+ statement; | |
+ // comment 1 | |
+ // comment 2 | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_028.txt b/src/testdir/test_cindent/test_028.txt | |
new file mode 100644 | |
index 0000000..1843901 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_028.txt | |
@@ -0,0 +1,11 @@ | |
+ | |
+class CAbc | |
+{ | |
+ int Test() { return FALSE; } | |
+ | |
+public: // comment | |
+ void testfall(); | |
+protected: | |
+ void testfall(); | |
+}; | |
+ | |
diff --git a/src/testdir/test_cindent/test_029.txt b/src/testdir/test_cindent/test_029.txt | |
new file mode 100644 | |
index 0000000..bfcd6ef | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_029.txt | |
@@ -0,0 +1,10 @@ | |
+ | |
+class Foo : public Bar | |
+{ | |
+ public: | |
+ virtual void method1(void) = 0; | |
+ virtual void method2(int arg1, | |
+ int arg2, | |
+ int arg3) = 0; | |
+}; | |
+ | |
diff --git a/src/testdir/test_cindent/test_030.txt b/src/testdir/test_cindent/test_030.txt | |
new file mode 100644 | |
index 0000000..ee1bded | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_030.txt | |
@@ -0,0 +1,10 @@ | |
+ | |
+ void | |
+foo() | |
+{ | |
+ if (a) | |
+ { | |
+ } else | |
+ asdf; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_031.txt b/src/testdir/test_cindent/test_031.txt | |
new file mode 100644 | |
index 0000000..2fdbc4b | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_031.txt | |
@@ -0,0 +1,38 @@ | |
+ | |
+{ | |
+ averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( | |
+ asdasdf, | |
+ func(asdf, | |
+ asdfadsf), | |
+ asdfasdf | |
+ ); | |
+ | |
+ /* those are ugly, but consequent */ | |
+ | |
+ func()->asd(asdasdf, | |
+ averylongfunctionname( | |
+ abc, | |
+ dec)->averylongfunctionname( | |
+ asdfadsf, | |
+ asdfasdf, | |
+ asdfasdf, | |
+ ), | |
+ func(asdfadf, | |
+ asdfasdf | |
+ ), | |
+ asdasdf | |
+ ); | |
+ | |
+ averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( | |
+ abc, | |
+ dec)->asdfasdfasdf( | |
+ asdfadsf, | |
+ asdfasdf, | |
+ asdfasdf, | |
+ ), | |
+ func(asdfadf, | |
+ asdfasdf), | |
+ asdasdf | |
+ ); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_032.txt b/src/testdir/test_cindent/test_032.txt | |
new file mode 100644 | |
index 0000000..9141329 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_032.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+int main () | |
+{ | |
+ if (cond1 && | |
+ cond2 | |
+ ) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_033.txt b/src/testdir/test_cindent/test_033.txt | |
new file mode 100644 | |
index 0000000..b0a8008 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_033.txt | |
@@ -0,0 +1,10 @@ | |
+ | |
+void func(int a | |
+#if defined(FOO) | |
+ , int b | |
+ , int c | |
+#endif | |
+ ) | |
+{ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_034.txt b/src/testdir/test_cindent/test_034.txt | |
new file mode 100644 | |
index 0000000..e8332cb | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_034.txt | |
@@ -0,0 +1,11 @@ | |
+ | |
+ void | |
+func(int a | |
+#if defined(FOO) | |
+ , int b | |
+ , int c | |
+#endif | |
+ ) | |
+{ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_035.txt b/src/testdir/test_cindent/test_035.txt | |
new file mode 100644 | |
index 0000000..212f52d | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_035.txt | |
@@ -0,0 +1,72 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if(x==y) | |
+ if(y==z) | |
+ foo=1; | |
+ else { bar=1; | |
+ baz=2; | |
+ } | |
+ printf("Foo!\n"); | |
+} | |
+ | |
+void func1(void) | |
+{ | |
+ char* tab[] = {"foo", "bar", | |
+ "baz", "quux", | |
+ "this line used", "to be indented incorrectly"}; | |
+ foo(); | |
+} | |
+ | |
+void func2(void) | |
+{ | |
+ int tab[] = | |
+ {1, 2, | |
+ 3, 4, | |
+ 5, 6}; | |
+ | |
+ printf("This line used to be indented incorrectly.\n"); | |
+} | |
+ | |
+int foo[] | |
+#ifdef BAR | |
+ | |
+= { 1, 2, 3, | |
+ 4, 5, 6 } | |
+ | |
+#endif | |
+ ; | |
+int baz; | |
+ | |
+void func3(void) | |
+{ | |
+ int tab[] = { | |
+ 1, 2, | |
+ 3, 4, | |
+ 5, 6}; | |
+ | |
+ printf("Don't you dare indent this line incorrectly!\n"); | |
+} | |
+ | |
+ void | |
+func4(a, b, | |
+ c) | |
+ int a; | |
+ int b; | |
+ int c; | |
+{ | |
+} | |
+ | |
+ void | |
+func5( | |
+ int a, | |
+ int b) | |
+{ | |
+} | |
+ | |
+ void | |
+func6( | |
+ int a) | |
+{ | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_036.txt b/src/testdir/test_cindent/test_036.txt | |
new file mode 100644 | |
index 0000000..f8b7c18 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_036.txt | |
@@ -0,0 +1,25 @@ | |
+ | |
+void func(void) | |
+{ | |
+ int tab[] = | |
+ { | |
+ 1, 2, 3, | |
+ 4, 5, 6}; | |
+ | |
+ printf("Indent this line correctly!\n"); | |
+ | |
+ switch (foo) | |
+ { | |
+ case bar: | |
+ printf("bar"); | |
+ break; | |
+ case baz: { | |
+ printf("baz"); | |
+ break; | |
+ } | |
+ case quux: | |
+ printf("But don't break the indentation of this instruction\n"); | |
+ break; | |
+ } | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_037.txt b/src/testdir/test_cindent/test_037.txt | |
new file mode 100644 | |
index 0000000..caec378 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_037.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+void func(void) | |
+{ | |
+ cout << "a" | |
+ << "b" | |
+ << ") :" | |
+ << "c"; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_038.txt b/src/testdir/test_cindent/test_038.txt | |
new file mode 100644 | |
index 0000000..9b27216 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_038.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+void func(void) | |
+{ | |
+ /* | |
+ * This is a comment. | |
+ */ | |
+ foo(); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_039.txt b/src/testdir/test_cindent/test_039.txt | |
new file mode 100644 | |
index 0000000..41ed794 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_039.txt | |
@@ -0,0 +1,11 @@ | |
+ | |
+void func(void) | |
+{ | |
+ for (int i = 0; i < 10; ++i) | |
+ if (i & 1) { | |
+ foo(1); | |
+ } else | |
+ foo(0); | |
+ baz(); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_040.txt b/src/testdir/test_cindent/test_040.txt | |
new file mode 100644 | |
index 0000000..852ec63 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_040.txt | |
@@ -0,0 +1,27 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ func( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_041.txt b/src/testdir/test_cindent/test_041.txt | |
new file mode 100644 | |
index 0000000..f1fe174 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_041.txt | |
@@ -0,0 +1,27 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ func( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_042.txt b/src/testdir/test_cindent/test_042.txt | |
new file mode 100644 | |
index 0000000..f1a146a | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_042.txt | |
@@ -0,0 +1,28 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+ | |
+ c = c1 && | |
+ ( | |
+ c2 || | |
+ c3 | |
+ ) && c4; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_043.txt b/src/testdir/test_cindent/test_043.txt | |
new file mode 100644 | |
index 0000000..8a9f3f5 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_043.txt | |
@@ -0,0 +1,33 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ | |
+ a_long_line( | |
+ argument, | |
+ argument); | |
+ a_short_line(argument, | |
+ argument); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_044.txt b/src/testdir/test_cindent/test_044.txt | |
new file mode 100644 | |
index 0000000..82e40f9 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_044.txt | |
@@ -0,0 +1,22 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_045.txt b/src/testdir/test_cindent/test_045.txt | |
new file mode 100644 | |
index 0000000..2b6213b | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_045.txt | |
@@ -0,0 +1,31 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+ if (c123456789 | |
+ && (c22345 | |
+ || c3)) | |
+ printf("foo\n"); | |
+ | |
+ if ( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+ func( c1 | |
+ && ( c2 | |
+ || c3)) | |
+ foo; | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_046.txt b/src/testdir/test_cindent/test_046.txt | |
new file mode 100644 | |
index 0000000..e5c2254 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_046.txt | |
@@ -0,0 +1,18 @@ | |
+ | |
+void func(void) | |
+{ | |
+ if (condition1 | |
+ && condition2) | |
+ action(); | |
+ function(argument1 | |
+ && argument2); | |
+ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3)) | |
+ { | |
+ } | |
+} | |
+ | |
diff --git a/src/testdir/test_cindent/test_047.txt b/src/testdir/test_cindent/test_047.txt | |
new file mode 100644 | |
index 0000000..855fd96 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_047.txt | |
@@ -0,0 +1,86 @@ | |
+ | |
+NAMESPACESTART | |
+/* valid namespaces with normal indent */ | |
+namespace | |
+{ | |
+{ | |
+ 111111111111; | |
+} | |
+} | |
+namespace /* test */ | |
+{ | |
+11111111111111111; | |
+} | |
+namespace // test | |
+{ | |
+111111111111111111; | |
+} | |
+namespace | |
+{ | |
+111111111111111111; | |
+} | |
+namespace test | |
+{ | |
+111111111111111111; | |
+} | |
+namespace test::cpp17 | |
+{ | |
+111111111111111111; | |
+} | |
+namespace ::incorrectcpp17 | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test::incorrectcpp17:: | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test:incorrectcpp17 | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test:::incorrectcpp17 | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace{ | |
+111111111111111111; | |
+} | |
+namespace test{ | |
+111111111111111111; | |
+} | |
+namespace { | |
+111111111111111111; | |
+} | |
+namespace test { | |
+111111111111111111; | |
+namespace test2 { | |
+22222222222222222; | |
+} | |
+} | |
+ | |
+/* invalid namespaces use block indent */ | |
+namespace test test2 { | |
+ 111111111111111111111; | |
+} | |
+namespace11111111111 { | |
+ 111111111111; | |
+} | |
+namespace() { | |
+ 1111111111111; | |
+} | |
+namespace() | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test test2 | |
+{ | |
+ 1111111111111111111; | |
+} | |
+namespace111111111 | |
+{ | |
+ 111111111111111111; | |
+} | |
+NAMESPACEEND | |
+ | |
+ | |
diff --git a/src/testdir/test_cindent/test_048.txt b/src/testdir/test_cindent/test_048.txt | |
new file mode 100644 | |
index 0000000..cc94607 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_048.txt | |
@@ -0,0 +1,16 @@ | |
+ | |
+JSSTART | |
+var bar = { | |
+ foo: { | |
+ that: this, | |
+ some: ok, | |
+ }, | |
+ "bar":{ | |
+ a : 2, | |
+ b: "123abc", | |
+ x: 4, | |
+ "y": 5 | |
+ } | |
+} | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/test_049.txt b/src/testdir/test_cindent/test_049.txt | |
new file mode 100644 | |
index 0000000..3bc96dc | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_049.txt | |
@@ -0,0 +1,9 @@ | |
+ | |
+JSSTART | |
+var foo = [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+]; | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/test_050.txt b/src/testdir/test_cindent/test_050.txt | |
new file mode 100644 | |
index 0000000..f953146 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_050.txt | |
@@ -0,0 +1,11 @@ | |
+ | |
+JSSTART | |
+function bar() { | |
+ var foo = [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/test_051.txt b/src/testdir/test_cindent/test_051.txt | |
new file mode 100644 | |
index 0000000..534d870 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_051.txt | |
@@ -0,0 +1,62 @@ | |
+ | |
+JSSTART | |
+(function($){ | |
+ | |
+ if (cond && | |
+ cond) { | |
+ stmt; | |
+ } | |
+ window.something.left = | |
+ (width - 50 + offset) + "px"; | |
+ var class_name='myclass'; | |
+ | |
+ function private_method() { | |
+ } | |
+ | |
+ var public_method={ | |
+ method: function(options,args){ | |
+ private_method(); | |
+ } | |
+ } | |
+ | |
+ function init(options) { | |
+ | |
+ $(this).data(class_name+'_public',$.extend({},{ | |
+ foo: 'bar', | |
+ bar: 2, | |
+ foobar: [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ], | |
+ callback: function(){ | |
+ return true; | |
+ } | |
+ }, options||{})); | |
+ } | |
+ | |
+ $.fn[class_name]=function() { | |
+ | |
+ var _arguments=arguments; | |
+ return this.each(function(){ | |
+ | |
+ var options=$(this).data(class_name+'_public'); | |
+ if (!options) { | |
+ init.apply(this,_arguments); | |
+ | |
+ } else { | |
+ var method=public_method[_arguments[0]]; | |
+ | |
+ if (typeof(method)!='function') { | |
+ console.log(class_name+' has no method "'+_arguments[0]+'"'); | |
+ return false; | |
+ } | |
+ _arguments[0]=options; | |
+ method.apply(this,_arguments); | |
+ } | |
+ }); | |
+ } | |
+ | |
+})(jQuery); | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/test_052.txt b/src/testdir/test_cindent/test_052.txt | |
new file mode 100644 | |
index 0000000..6154404 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_052.txt | |
@@ -0,0 +1,18 @@ | |
+ | |
+JSSTART | |
+function init(options) { | |
+ $(this).data(class_name+'_public',$.extend({},{ | |
+ foo: 'bar', | |
+ bar: 2, | |
+ foobar: [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ], | |
+ callback: function(){ | |
+ return true; | |
+ } | |
+ }, options||{})); | |
+} | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/test_053.txt b/src/testdir/test_cindent/test_053.txt | |
new file mode 100644 | |
index 0000000..6956b61 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_053.txt | |
@@ -0,0 +1,20 @@ | |
+ | |
+JSSTART | |
+(function($){ | |
+ function init(options) { | |
+ $(this).data(class_name+'_public',$.extend({},{ | |
+ foo: 'bar', | |
+ bar: 2, | |
+ foobar: [ | |
+ 1, | |
+ 2, | |
+ 3 | |
+ ], | |
+ callback: function(){ | |
+ return true; | |
+ } | |
+ }, options||{})); | |
+ } | |
+})(jQuery); | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/test_054.txt b/src/testdir/test_cindent/test_054.txt | |
new file mode 100644 | |
index 0000000..4006f57 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/test_054.txt | |
@@ -0,0 +1,153 @@ | |
+ | |
+JSSTART | |
+// Results of JavaScript indent | |
+// 1 | |
+(function(){ | |
+ var a = [ | |
+ 'a', | |
+ 'b', | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+ ]; | |
+}()) | |
+ | |
+// 2 | |
+(function(){ | |
+ var a = [ | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'a', | |
+ 'b', | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+ ]; | |
+}()) | |
+ | |
+// 3 | |
+(function(){ | |
+ var a = [ | |
+ 0 + | |
+ // comment 1 | |
+ 5 * | |
+ /* comment 2 */ | |
+ 9 * | |
+ 'a', | |
+ 'b', | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+ ]; | |
+}()) | |
+ | |
+// 4 | |
+{ | |
+ var a = [ | |
+ 0, | |
+ 1 | |
+ ]; | |
+ var b; | |
+ var c; | |
+} | |
+ | |
+// 5 | |
+{ | |
+ var a = [ | |
+ [ | |
+ 0 | |
+ ], | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+ | |
+// 6 | |
+{ | |
+ var a = [ | |
+ [ | |
+ 0, | |
+ 1 | |
+ ], | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+ | |
+// 7 | |
+{ | |
+ var a = [ | |
+ // [ | |
+ 0, | |
+ // 1 | |
+ // ], | |
+ 2, | |
+ 3 | |
+ ]; | |
+} | |
+ | |
+// 8 | |
+var x = [ | |
+ (function(){ | |
+ var a, | |
+ b, | |
+ c, | |
+ d, | |
+ e, | |
+ f, | |
+ g, | |
+ h, | |
+ i; | |
+ }) | |
+]; | |
+ | |
+// 9 | |
+var a = [ | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'a', | |
+ 'b', | |
+ 0 + | |
+ 5 * | |
+ 9 * | |
+ 'c', | |
+ 'd', | |
+ 'e', | |
+ 'f', | |
+ 'g', | |
+ 'h', | |
+ 'i' | |
+]; | |
+ | |
+// 10 | |
+var a, | |
+ b, | |
+ c, | |
+ d, | |
+ e, | |
+ f, | |
+ g, | |
+ h, | |
+ i; | |
+JSEND | |
+ | |
diff --git a/src/testdir/test_cindent/xx.txt b/src/testdir/test_cindent/xx.txt | |
new file mode 100644 | |
index 0000000..ad16a88 | |
--- /dev/null | |
+++ b/src/testdir/test_cindent/xx.txt | |
@@ -0,0 +1,959 @@ | |
+ | |
+/* start of AUTO matically checked vim: set ts=4 : */ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ else | |
+ } | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ while (this) | |
+ if (test) | |
+ cmd1; | |
+ else | |
+ cmd2; | |
+} | |
+ | |
+{ | |
+ if (test) | |
+ { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) | |
+ cmd; | |
+} | |
+ | |
+{ | |
+ if (test) { | |
+ cmd; | |
+ } | |
+ | |
+ if (test) cmd; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+} | |
+ | |
+{ | |
+ cmd1; | |
+ for (blah) | |
+ while (this) | |
+ if (test) | |
+ cmd2; | |
+ cmd3; | |
+ | |
+ if (test) | |
+ { | |
+ cmd1; | |
+ cmd2; | |
+ cmd3; | |
+ } | |
+} | |
+ | |
+ | |
+/* Test for 'cindent' do/while mixed with if/else: */ | |
+ | |
+{ | |
+ do | |
+ if (asdf) | |
+ asdfasd; | |
+ while (cond); | |
+ | |
+ do | |
+ if (asdf) | |
+ while (asdf) | |
+ asdf; | |
+ while (asdf); | |
+} | |
+ | |
+/* Test for 'cindent' with two ) on a continuation line */ | |
+{ | |
+ if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d | |
+ aal;sdkjf ( ;asldfkja;sldfk | |
+ al;sdjfka ;slkdf ) sa;ldkjfsa dlk;) | |
+ line up here; | |
+} | |
+ | |
+ | |
+/* C++ tests: */ | |
+ | |
+// foo() these three lines should remain in column 0 | |
+// { | |
+// } | |
+ | |
+/* Test for continuation and unterminated lines: */ | |
+{ | |
+ i = 99 + 14325 + | |
+ 21345 + | |
+ 21345 + | |
+ 21345 + ( 21345 + | |
+ 21345) + | |
+ 2345 + | |
+ 1234; | |
+ c = 1; | |
+} | |
+ | |
+/* | |
+ testje for indent with empty line | |
+ | |
+ here */ | |
+ | |
+{ | |
+ if (testing && | |
+ not a joke || | |
+ line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ )line up here) | |
+ hay; | |
+ if (testing && | |
+ (not a joke || testing | |
+ line up here)) | |
+ hay; | |
+} | |
+ | |
+ | |
+{ | |
+ switch (c) | |
+ { | |
+ case xx: | |
+ do | |
+ if (asdf) | |
+ do | |
+ asdfasdf; | |
+ while (asdf); | |
+ else | |
+ asdfasdf; | |
+ while (cond); | |
+ case yy: | |
+ case xx: | |
+ case zz: | |
+ testing; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (cond) { | |
+ foo; | |
+ } | |
+ else | |
+ { | |
+ bar; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf | |
+ alsdkfj (asldk;fj | |
+ awith cino=(0 ;lf this one goes to below the paren with == | |
+ ;laksjfd ;lsakdjf ;alskdf asd) | |
+ asdfasdf;))) | |
+ asdfasdf; | |
+} | |
+ | |
+ int | |
+func(a, b) | |
+ int a; | |
+ int c; | |
+{ | |
+ if (c1 && (c2 || | |
+ c3)) | |
+ foo; | |
+ if (c1 && | |
+ (c2 || c3) | |
+ ) | |
+} | |
+ | |
+{ | |
+ while (asd) | |
+ { | |
+ if (asdf) | |
+ if (test) | |
+ if (that) | |
+ { | |
+ if (asdf) | |
+ do | |
+ cdasd; | |
+ while (as | |
+ df); | |
+ } | |
+ else | |
+ if (asdf) | |
+ asdf; | |
+ else | |
+ asdf; | |
+ asdf; | |
+ } | |
+} | |
+ | |
+{ | |
+ s = "/*"; b = ';' | |
+ s = "/*"; b = ';'; | |
+ a = b; | |
+} | |
+ | |
+{ | |
+ switch (a) | |
+ { | |
+ case a: | |
+ switch (t) | |
+ { | |
+ case 1: | |
+ cmd; | |
+ break; | |
+ case 2: | |
+ cmd; | |
+ break; | |
+ } | |
+ cmd; | |
+ break; | |
+ case b: | |
+ { | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ case c: { | |
+ int i; | |
+ cmd; | |
+ } | |
+ case d: if (cond && | |
+ test) { /* this line doesn't work right */ | |
+ int i; | |
+ cmd; | |
+ } | |
+ break; | |
+ } | |
+} | |
+ | |
+{ | |
+ if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) && | |
+ (bp_to->b_p_initialized || | |
+ (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) | |
+ return; | |
+label : | |
+ asdf = asdf ? | |
+ asdf : asdf; | |
+ asdf = asdf ? | |
+ asdf: asdf; | |
+} | |
+ | |
+/* Special Comments : This function has the added complexity (compared */ | |
+/* : to addtolist) of having to check for a detail */ | |
+/* : texture and add that to the list first. */ | |
+ | |
+char *(array[100]) = { | |
+ "testje", | |
+ "foo", | |
+ "bar", | |
+} | |
+ | |
+enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+typedef enum soppie | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+}; | |
+ | |
+static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+public static enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+static private enum | |
+{ | |
+ yes = 0, | |
+ no, | |
+ maybe | |
+} soppie; | |
+ | |
+{ | |
+ int a, | |
+ b; | |
+} | |
+ | |
+{ | |
+ struct Type | |
+ { | |
+ int i; | |
+ char *str; | |
+ } var[] = | |
+ { | |
+ 0, "zero", | |
+ 1, "one", | |
+ 2, "two", | |
+ 3, "three" | |
+ }; | |
+ | |
+ float matrix[3][3] = | |
+ { | |
+ { | |
+ 0, | |
+ 1, | |
+ 2 | |
+ }, | |
+ { | |
+ 3, | |
+ 4, | |
+ 5 | |
+ }, | |
+ { | |
+ 6, | |
+ 7, | |
+ 8 | |
+ } | |
+ }; | |
+} | |
+ | |
+{ | |
+ /* blah ( blah */ | |
+ /* where does this go? */ | |
+ | |
+ /* blah ( blah */ | |
+ cmd; | |
+ | |
+ func(arg1, | |
+ /* comment */ | |
+ arg2); | |
+ a; | |
+ { | |
+ b; | |
+ { | |
+ c; /* Hey, NOW it indents?! */ | |
+ } | |
+ } | |
+ | |
+ { | |
+ func(arg1, | |
+ arg2, | |
+ arg3); | |
+ /* Hey, what am I doing here? Is this coz of the ","? */ | |
+ } | |
+} | |
+ | |
+main () | |
+{ | |
+ if (cond) | |
+ { | |
+ a = b; | |
+ } | |
+ if (cond) { | |
+ a = c; | |
+ } | |
+ if (cond) | |
+ a = d; | |
+ return; | |
+} | |
+ | |
+{ | |
+ case 2: if (asdf && | |
+ asdfasdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 3: if (asdf) | |
+ aasdf; | |
+ a = 9; | |
+ case 4: x = 1; | |
+ y = 2; | |
+ | |
+label: if (asdf) | |
+ here; | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ { | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) { | |
+ there; | |
+ } | |
+ | |
+label: if (asdf && | |
+ asdfasdf) | |
+ there; | |
+} | |
+ | |
+{ | |
+ /* | |
+ hello with ":set comments= cino=c5" | |
+ */ | |
+ | |
+ /* | |
+ hello with ":set comments= cino=" | |
+ */ | |
+} | |
+ | |
+ | |
+{ | |
+ if (a < b) { | |
+ a = a + 1; | |
+ } else | |
+ a = a + 2; | |
+ | |
+ if (a) | |
+ do { | |
+ testing; | |
+ } while (asdfasdf); | |
+ a = b + 1; | |
+ asdfasdf | |
+} | |
+ | |
+{ | |
+ for ( int i = 0; | |
+ i < 10; i++ ) | |
+ { | |
+ } | |
+ i = 0; | |
+} | |
+ | |
+class bob | |
+{ | |
+ int foo() {return 1;} | |
+ int bar; | |
+} | |
+ | |
+main() | |
+{ | |
+ while(1) | |
+ if (foo) | |
+ { | |
+ bar; | |
+ } | |
+ else { | |
+ asdf; | |
+ } | |
+ misplacedline; | |
+} | |
+ | |
+{ | |
+ if (clipboard.state == SELECT_DONE | |
+ && ((row == clipboard.start.lnum | |
+ && col >= clipboard.start.col) | |
+ || row > clipboard.start.lnum)) | |
+} | |
+ | |
+{ | |
+ if (1) {i += 4;} | |
+ where_am_i; | |
+ return 0; | |
+} | |
+ | |
+{ | |
+ { | |
+ } // sdf(asdf | |
+ if (asdf) | |
+ asd; | |
+} | |
+ | |
+{ | |
+label1: | |
+label2: | |
+} | |
+ | |
+{ | |
+ int fooRet = foo(pBar1, false /*fKB*/, | |
+ true /*fPTB*/, 3 /*nT*/, false /*fDF*/); | |
+ f() { | |
+ for ( i = 0; | |
+ i < m; | |
+ /* c */ i++ ) { | |
+ a = b; | |
+ } | |
+ } | |
+} | |
+ | |
+{ | |
+ f1(/*comment*/); | |
+ f2(); | |
+} | |
+ | |
+{ | |
+ do { | |
+ if (foo) { | |
+ } else | |
+ ; | |
+ } while (foo); | |
+ foo(); // was wrong | |
+} | |
+ | |
+int x; // no extra indent because of the ; | |
+void func() | |
+{ | |
+} | |
+ | |
+char *tab[] = {"aaa", | |
+ "};", /* }; */ NULL} | |
+ int indented; | |
+{} | |
+ | |
+char *a[] = {"aaa", "bbb", | |
+ "ccc", NULL}; | |
+// here | |
+ | |
+char *tab[] = {"aaa", | |
+ "xx", /* xx */}; /* asdf */ | |
+int not_indented; | |
+ | |
+{ | |
+ do { | |
+ switch (bla) | |
+ { | |
+ case 1: if (foo) | |
+ bar; | |
+ } | |
+ } while (boo); | |
+ wrong; | |
+} | |
+ | |
+int foo, | |
+ bar; | |
+int foo; | |
+ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+char * xx = "asdf\ | |
+ foo\ | |
+ bor"; | |
+int x; | |
+ | |
+char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ | |
+void f() | |
+{ | |
+#if defined(foo) \ | |
+ && defined(bar) | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ { | |
+ int i; | |
+ char *foo = "asdf\ | |
+ asdf\ | |
+ asdf", | |
+ *bar; | |
+ } | |
+#endif | |
+} | |
+#endif | |
+ | |
+int y; // comment | |
+// comment | |
+ | |
+// comment | |
+ | |
+{ | |
+ Constructor(int a, | |
+ int b ) : BaseClass(a) | |
+ { | |
+ } | |
+} | |
+ | |
+void foo() | |
+{ | |
+ char one, | |
+ two; | |
+ struct bla piet, | |
+ jan; | |
+ enum foo kees, | |
+ jannie; | |
+ static unsigned sdf, | |
+ krap; | |
+ unsigned int piet, | |
+ jan; | |
+ int | |
+ kees, | |
+ jan; | |
+} | |
+ | |
+{ | |
+ t(int f, | |
+ int d); // ) | |
+ d(); | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b), | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) : | |
+ BaseClass(a) | |
+{ | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b ) /*x*/ : /*x*/ BaseClass(a), | |
+ member(b) | |
+{ | |
+} | |
+ | |
+A::A(int a, int b) | |
+ : aa(a), | |
+ bb(b), | |
+ cc(c) | |
+{ | |
+} | |
+ | |
+class CAbc : | |
+ public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+ int Test() { return FALSE; } | |
+ int Test1() { return TRUE; } | |
+ | |
+ CAbc(int a, int b ) : | |
+ BaseClass(a) | |
+ { | |
+ switch(xxx) | |
+ { | |
+ case abc: | |
+ asdf(); | |
+ break; | |
+ | |
+ case 999: | |
+ baer(); | |
+ break; | |
+ } | |
+ } | |
+ | |
+ public: // <-- this was incoreectly indented before!! | |
+ void testfall(); | |
+ protected: | |
+ void testfall(); | |
+}; | |
+ | |
+class CAbc : public BaseClass1, | |
+ protected BaseClass2 | |
+{ | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { | |
+ 123, | |
+ 456 | |
+ }, | |
+ { | |
+ 123, | |
+ 456 | |
+ } | |
+}; | |
+ | |
+static struct | |
+{ | |
+ int a; | |
+ int b; | |
+} variable[COUNT] = | |
+{ | |
+ { 123, 456 }, | |
+ { 123, 456 } | |
+}; | |
+ | |
+void asdf() /* ind_maxparen may cause trouble here */ | |
+{ | |
+ if ((0 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1 | |
+ && 1)) break; | |
+} | |
+ | |
+foo() | |
+{ | |
+ a = cond ? foo() : asdf | |
+ + asdf; | |
+ | |
+ a = cond ? | |
+ foo() : asdf | |
+ + asdf; | |
+} | |
+ | |
+int main(void) | |
+{ | |
+ if (a) | |
+ if (b) | |
+ 2; | |
+ else 3; | |
+ next_line_of_code(); | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, | |
+ int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+barry() | |
+{ | |
+ Foo::Foo (int one, int two) | |
+ : something(4) | |
+ {} | |
+} | |
+ | |
+Constructor::Constructor(int a, | |
+ int b | |
+ ) : | |
+ BaseClass(a, | |
+ b, | |
+ c), | |
+ mMember(b) | |
+{ | |
+} | |
+int main () | |
+{ | |
+ if (lala) | |
+ do | |
+ ++(*lolo); | |
+ while (lili | |
+ && lele); | |
+ lulu; | |
+} | |
+ | |
+int main () | |
+{ | |
+ switch (c) | |
+ { | |
+ case 'c': if (cond) | |
+ { | |
+ } | |
+ } | |
+} | |
+ | |
+main() | |
+{ | |
+ (void) MyFancyFuasdfadsfnction( | |
+ argument); | |
+} | |
+ | |
+main() | |
+{ | |
+ char foo[] = "/*"; | |
+ /* as | |
+ df */ | |
+ hello | |
+} | |
+ | |
+/* valid namespaces with normal indent */ | |
+namespace | |
+{ | |
+ { | |
+ 111111111111; | |
+ } | |
+} | |
+namespace /* test */ | |
+{ | |
+ 11111111111111111; | |
+} | |
+namespace // test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace{ | |
+ 111111111111111111; | |
+} | |
+namespace test{ | |
+ 111111111111111111; | |
+} | |
+namespace { | |
+ 111111111111111111; | |
+} | |
+namespace test { | |
+ 111111111111111111; | |
+ namespace test2 { | |
+ 22222222222222222; | |
+ } | |
+} | |
+ | |
+/* invalid namespaces use block indent */ | |
+namespace test test2 { | |
+ 111111111111111111111; | |
+} | |
+namespace11111111111 { | |
+ 111111111111; | |
+} | |
+namespace() { | |
+ 1111111111111; | |
+} | |
+namespace() | |
+{ | |
+ 111111111111111111; | |
+} | |
+namespace test test2 | |
+{ | |
+ 1111111111111111111; | |
+} | |
+namespace111111111 | |
+{ | |
+ 111111111111111111; | |
+} | |
+ | |
+void getstring() { | |
+ /* Raw strings */ | |
+ const char* s = R"( | |
+test { | |
+# comment | |
+field: 123 | |
+} | |
+)"; | |
+ } | |
+ | |
+void getstring() { | |
+ const char* s = R"foo( | |
+test { | |
+# comment | |
+field: 123 | |
+} | |
+)foo"; | |
+ } | |
+ | |
+{ | |
+ int a[4] = { | |
+ [0] = 0, | |
+ [1] = 1, | |
+ [2] = 2, | |
+ [3] = 3, | |
+ }; | |
+} | |
+ | |
+{ | |
+ a = b[2] | |
+ + 3; | |
+} | |
+ | |
+{ | |
+ if (1) | |
+ /* aaaaa | |
+ * bbbbb | |
+ */ | |
+ a = 1; | |
+} | |
+ | |
+void func() | |
+{ | |
+ switch (foo) | |
+ { | |
+ case (bar): | |
+ if (baz()) | |
+ quux(); | |
+ break; | |
+ case (shmoo): | |
+ if (!bar) | |
+ { | |
+ } | |
+ case (foo1): | |
+ switch (bar) | |
+ { | |
+ case baz: | |
+ baz_f(); | |
+ break; | |
+ } | |
+ break; | |
+ default: | |
+ baz(); | |
+ baz(); | |
+ break; | |
+ } | |
+} | |
+ | |
+/* end of AUTO */ | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment