aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ASTMatchers/ASTMatchersNodeTest.cpp23
-rw-r--r--unittests/Format/FormatTestJS.cpp6
2 files changed, 29 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 5c29334222df..dfaa441cd764 100644
--- a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1020,6 +1020,29 @@ TEST(InitListExpression, MatchesInitListExpression) {
matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42))));
}
+TEST(CXXStdInitializerListExpression, MatchesCXXStdInitializerListExpression) {
+ const std::string code = "namespace std {"
+ "template <typename> class initializer_list {"
+ " public: initializer_list() noexcept {}"
+ "};"
+ "}"
+ "struct A {"
+ " A(std::initializer_list<int>) {}"
+ "};";
+ EXPECT_TRUE(matches(code + "A a{0};",
+ cxxConstructExpr(has(cxxStdInitializerListExpr()),
+ hasDeclaration(cxxConstructorDecl(
+ ofClass(hasName("A")))))));
+ EXPECT_TRUE(matches(code + "A a = {0};",
+ cxxConstructExpr(has(cxxStdInitializerListExpr()),
+ hasDeclaration(cxxConstructorDecl(
+ ofClass(hasName("A")))))));
+
+ EXPECT_TRUE(notMatches("int a[] = { 1, 2 };", cxxStdInitializerListExpr()));
+ EXPECT_TRUE(notMatches("struct B { int x, y; }; B b = { 5, 6 };",
+ cxxStdInitializerListExpr()));
+}
+
TEST(UsingDeclaration, MatchesUsingDeclarations) {
EXPECT_TRUE(matches("namespace X { int x; } using X::x;",
usingDecl()));
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index eda9e0a31da4..9144fe17e9ec 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,11 @@ TEST_F(FormatTestJS, ImportComments) {
getGoogleJSStyleWithColumns(25));
verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
}
+
+TEST_F(FormatTestJS, Exponentiation) {
+ verifyFormat("squared = x ** 2;");
+ verifyFormat("squared **= 2;");
+}
+
} // end namespace tooling
} // end namespace clang