================
@@ -4266,6 +4266,140 @@ TEST_F(FormatTest, FormatsTypedefEnum) {
                Style);
 }
 
+TEST_F(FormatTest, FormatsVaOptWithTrailingComma) {
+  verifyFormat("#define DEFINE_DESCRIPTOR(Name, ...) \\\n"
+               "  enum ParameterIndices {            \\\n"
+               "    kJSTarget = -1,                  \\\n"
+               "    __VA_OPT__(__VA_ARGS__, )        \\\n"
+               "    kNewTarget,                      \\\n"
+               "    kActualArgumentsCount,           \\\n"
+               "    kContext,                        \\\n"
+               "    kParameterCount,                 \\\n"
+               "  };",
+               getChromiumStyle(FormatStyle::LK_Cpp));
+
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignEscapedNewlines = FormatStyle::ENAS_Left;
+
+  verifyFormat("#define M(...) enum E { __VA_OPT__(__VA_ARGS__, ) kOnly };",
+               Style);
+  FormatStyle NoShortEnums = Style;
+  NoShortEnums.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("#define M(...)                \\\n"
+               "  enum E {                    \\\n"
+               "    __VA_OPT__(__VA_ARGS__, ) \\\n"
+               "    kOnly                     \\\n"
+               "  };",
+               NoShortEnums);
+
+  FormatStyle InsertComma = NoShortEnums;
+  InsertComma.EnumTrailingComma = FormatStyle::ETC_Insert;
----------------
HazardyKnusperkeks wrote:

If you want to test the comma insertion, you need the 3 argument `verifyFormat`.

https://github.com/llvm/llvm-project/pull/240902
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to