summaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Format/FormatTestJS.cpp')
-rw-r--r--unittests/Format/FormatTestJS.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index d8fa8e4b942ce..7886c4fe27ad8 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -24,10 +24,10 @@ protected:
DEBUG(llvm::errs() << "---\n");
DEBUG(llvm::errs() << Code << "\n\n");
std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
- bool IncompleteFormat = false;
+ FormattingAttemptStatus Status;
tooling::Replacements Replaces =
- reformat(Style, Code, Ranges, "<stdin>", &IncompleteFormat);
- EXPECT_FALSE(IncompleteFormat);
+ reformat(Style, Code, Ranges, "<stdin>", &Status);
+ EXPECT_TRUE(Status.FormatComplete);
auto Result = applyAllReplacements(Code, Replaces);
EXPECT_TRUE(static_cast<bool>(Result));
DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -318,6 +318,25 @@ TEST_F(FormatTestJS, MethodsInObjectLiterals) {
"};");
}
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+ // Don't break after "protected"
+ verifyFormat("class X {\n"
+ " protected get getter():\n"
+ " number {\n"
+ " return 1;\n"
+ " }\n"
+ "}",
+ getGoogleJSStyleWithColumns(12));
+ // Don't break after "get"
+ verifyFormat("class X {\n"
+ " protected get someReallyLongGetterName():\n"
+ " number {\n"
+ " return 1;\n"
+ " }\n"
+ "}",
+ getGoogleJSStyleWithColumns(40));
+}
+
TEST_F(FormatTestJS, SpacesInContainerLiterals) {
verifyFormat("var arr = [1, 2, 3];");
verifyFormat("f({a: 1, b: 2, c: 3});");
@@ -1220,6 +1239,9 @@ TEST_F(FormatTestJS, MetadataAnnotations) {
"}");
verifyFormat("class X {}\n"
"class Y {}");
+ verifyFormat("class X {\n"
+ " @property() private isReply = false;\n"
+ "}\n");
}
TEST_F(FormatTestJS, TypeAliases) {