This is an archive of the discontinued LLVM Phabricator instance.

[clang-format][NFC] Clean up unit tests
ClosedPublic

Authored by owenpan on Jun 16 2023, 12:39 AM.

Details

Summary

This patch adds a verifyNoChange macro to verify code that won't change after being formatted. (The code will not be messed up before being formatted.) It then replaces EXPECT_EQ with verifyFormat wherever applicable so that the code will be messed up before being formatted. When the replacement fails the unit test, verifyFormat is replaced with verifyNoChange.

Diff Detail

Event Timeline

owenpan created this revision.Jun 16 2023, 12:39 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJun 16 2023, 12:39 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
owenpan requested review of this revision.Jun 16 2023, 12:39 AM
owenpan updated this revision to Diff 532192.Jun 16 2023, 9:36 AM

Cleaned up FormatTestJS.cpp as well.

This revision is now accepted and ready to land.Jun 16 2023, 10:02 AM

Because FormatTestCSharp.cpp, FormatTestJS.cpp, and FormatTestSelective.cpp don't #include FormatTestBase.h, they can't benefit from verifyNoChange. However, the rest of the unit tests are all free of the repeated arguments in EXPECT_EQ and verifyFormat (as far as my script could identify and replace).

This revision was automatically updated to reflect the committed changes.