summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorMark Zeren <mzeren@vmware.com>2018-04-04 21:09:00 +0000
committerMark Zeren <mzeren@vmware.com>2018-04-04 21:09:00 +0000
commitc9a918c560aa2f524815dfb4ec68c3b24f3b211a (patch)
treec31164d46b959f09f361b903e211675a2c7bc627 /clang/unittests/Format/FormatTestJS.cpp
parenta5531f287a4499586afd3ef2501a71c362eb6cc8 (diff)
downloadbcm5719-llvm-c9a918c560aa2f524815dfb4ec68c3b24f3b211a.tar.gz
bcm5719-llvm-c9a918c560aa2f524815dfb4ec68c3b24f3b211a.zip
[clang-format] In tests, expected code should be format-stable
Summary: Extend various verifyFormat helper functions to check that the expected text is "stable". This provides some protection against bugs where formatting results are ocilating between two forms, or continually change in some other way. Testing Done: * Ran unit tests. * Reproduced a known instability in preprocessor indentation which was caught by this new check. Reviewers: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42034 llvm-svn: 329231
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 5fb47a7d32f..347118353e3 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -49,6 +49,8 @@ protected:
static void verifyFormat(
llvm::StringRef Code,
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
+ EXPECT_EQ(Code.str(), format(Code, Style))
+ << "Expected code is not stable";
std::string Result = format(test::messUp(Code), Style);
EXPECT_EQ(Code.str(), Result) << "Formatted:\n" << Result;
}
@@ -57,6 +59,8 @@ protected:
llvm::StringRef Expected,
llvm::StringRef Code,
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
+ EXPECT_EQ(Expected.str(), format(Expected, Style))
+ << "Expected code is not stable";
std::string Result = format(Code, Style);
EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
}
OpenPOWER on IntegriCloud