diff options
author | Jonathan Coe <jbcoe@google.com> | 2020-06-08 21:22:02 +0100 |
---|---|---|
committer | Jonathan Coe <jbcoe@google.com> | 2020-06-09 10:20:01 +0100 |
commit | 7117066bd6182f53ec9f97d2e5e81de27c2e0db0 (patch) | |
tree | ed103e42c36f50373b1016a97e5f7a0ec9d73748 /clang/unittests/Format/FormatTestCSharp.cpp | |
parent | 3323a628ec821b8b75d3b60bf1510931f97d3883 (diff) | |
download | llvm-7117066bd6182f53ec9f97d2e5e81de27c2e0db0.zip llvm-7117066bd6182f53ec9f97d2e5e81de27c2e0db0.tar.gz llvm-7117066bd6182f53ec9f97d2e5e81de27c2e0db0.tar.bz2 |
[clang-format] Brace breaking for C# lambdas
Reviewers: krasimir, MyDeveloperDay
Reviewed By: krasimir
Subscribers: cfe-commits
Tags: #clang-format, #clang
Differential Revision: https://reviews.llvm.org/D81394
Diffstat (limited to 'clang/unittests/Format/FormatTestCSharp.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestCSharp.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp index 584b8ae..bcf2c7a 100644 --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -525,6 +525,33 @@ var x = foo(className, $@"some code: EXPECT_EQ(Code, format(Code, Style)); } +TEST_F(FormatTestCSharp, CSharpLambdas) { + FormatStyle GoogleStyle = getGoogleStyle(FormatStyle::LK_CSharp); + FormatStyle MicrosoftStyle = getMicrosoftStyle(FormatStyle::LK_CSharp); + + verifyFormat(R"(// +class MyClass { + Action<string> greet = name => { + string greeting = $"Hello {name}!"; + Console.WriteLine(greeting); + }; +})", + GoogleStyle); + + // Microsoft Style: + // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions#statement-lambdas + verifyFormat(R"(// +class MyClass +{ + Action<string> greet = name => + { + string greeting = $"Hello {name}!"; + Console.WriteLine(greeting); + }; +})", + MicrosoftStyle); +} + TEST_F(FormatTestCSharp, CSharpObjectInitializers) { FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp); |