summaryrefslogtreecommitdiff
path: root/unittests/Format/CleanupTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/Format/CleanupTest.cpp')
-rw-r--r--unittests/Format/CleanupTest.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/unittests/Format/CleanupTest.cpp b/unittests/Format/CleanupTest.cpp
index e554a8191277a..708fdf896890c 100644
--- a/unittests/Format/CleanupTest.cpp
+++ b/unittests/Format/CleanupTest.cpp
@@ -36,11 +36,12 @@ protected:
// Returns code after cleanup around \p Offsets.
std::string cleanupAroundOffsets(llvm::ArrayRef<unsigned> Offsets,
- llvm::StringRef Code) {
+ llvm::StringRef Code,
+ const FormatStyle &Style = getLLVMStyle()) {
std::vector<tooling::Range> Ranges;
for (auto Offset : Offsets)
Ranges.push_back(tooling::Range(Offset, 0));
- return cleanup(Code, Ranges);
+ return cleanup(Code, Ranges, Style);
}
};
@@ -171,6 +172,14 @@ TEST_F(CleanupTest, ListRedundantComma) {
EXPECT_EQ(Expected, cleanupAroundOffsets({17, 22}, Code));
}
+TEST_F(CleanupTest, NoCleanupsForJavaScript) {
+ std::string Code = "function f() { var x = [a, b, , c]; }";
+ std::string Expected = "function f() { var x = [a, b, , c]; }";
+ const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+
+ EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code, Style));
+}
+
TEST_F(CleanupTest, TrailingCommaInParens) {
std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";