diff options
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); |