aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Format')
-rw-r--r--unittests/Format/FormatTest.cpp11
-rw-r--r--unittests/Format/FormatTestJS.cpp11
-rw-r--r--unittests/Format/SortImportsTestJS.cpp17
3 files changed, 39 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 937362f5c9d7..f533ebf2234b 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -333,6 +333,16 @@ TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
verifyFormat("x = (a) xor (b);");
}
+TEST_F(FormatTest, RecognizesUnaryOperatorKeywords) {
+ verifyFormat("x = compl(a);");
+ verifyFormat("x = not(a);");
+ verifyFormat("x = bitand(a);");
+ // Unary operator must not be merged with the next identifier
+ verifyFormat("x = compl a;");
+ verifyFormat("x = not a;");
+ verifyFormat("x = bitand a;");
+}
+
//===----------------------------------------------------------------------===//
// Tests for control statements.
//===----------------------------------------------------------------------===//
@@ -5340,6 +5350,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("x = *a(x) = *a(y);", Left);
verifyFormat("for (;; *a = b) {\n}", Left);
verifyFormat("return *this += 1;", Left);
+ verifyFormat("throw *x;", Left);
verifyIndependentOfContext("a = *(x + y);");
verifyIndependentOfContext("a = &(x + y);");
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index 11e386a1c7c7..c256ebe46263 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -1464,6 +1464,17 @@ TEST_F(FormatTestJS, ImportWrapping) {
" A,\n"
"} from 'some/module.js';",
Style);
+ Style.ColumnLimit = 40;
+ // Using this version of verifyFormat because test::messUp hides the issue.
+ verifyFormat("import {\n"
+ " A,\n"
+ "} from\n"
+ " 'some/path/longer/than/column/limit/module.js';",
+ " import { \n"
+ " A, \n"
+ " } from\n"
+ " 'some/path/longer/than/column/limit/module.js' ; ",
+ Style);
}
TEST_F(FormatTestJS, TemplateStrings) {
diff --git a/unittests/Format/SortImportsTestJS.cpp b/unittests/Format/SortImportsTestJS.cpp
index 7e766e1969e1..4208b29702dd 100644
--- a/unittests/Format/SortImportsTestJS.cpp
+++ b/unittests/Format/SortImportsTestJS.cpp
@@ -283,6 +283,23 @@ TEST_F(SortImportsTestJS, SortCaseInsensitive) {
"1;");
}
+TEST_F(SortImportsTestJS, SortMultiLine) {
+ // Reproduces issue where multi-line import was not parsed correctly.
+ verifySort("import {A} from 'a';\n"
+ "import {A} from 'b';\n"
+ "\n"
+ "1;",
+ "import\n"
+ "{\n"
+ "A\n"
+ "}\n"
+ "from\n"
+ "'b';\n"
+ "import {A} from 'a';\n"
+ "\n"
+ "1;");
+}
+
} // end namespace
} // end namespace format
} // end namespace clang