Skip to content

Commit

Permalink
Add test from PR 50799 for impl PR 56853 (#57752)
Browse files Browse the repository at this point in the history
* Add test "TestInterpolatedStringWithNewLinesInExpression()" which was implemented as part of #50799 and later realized via #56853
  • Loading branch information
bernd5 authored Dec 13, 2021
1 parent 8bc5048 commit 498d5b1
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/Compilers/CSharp/Test/Syntax/Parsing/ExpressionParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,81 @@ void M()
EOF();
}

[Fact]
public void TestInterpolatedStringWithNewLinesInExpression()
{
var text = @"$""Text with {
new[] {
1, 2, 3
}[2]
} parts and new line expressions!""";

UsingExpression(text, TestOptions.RegularPreview);

var expr = (InterpolatedStringExpressionSyntax)N(SyntaxKind.InterpolatedStringExpression);
{
N(SyntaxKind.InterpolatedStringStartToken);
N(SyntaxKind.InterpolatedStringText);
{
N(SyntaxKind.InterpolatedStringTextToken);
}
N(SyntaxKind.Interpolation);
{
N(SyntaxKind.OpenBraceToken);
N(SyntaxKind.ElementAccessExpression);
{
N(SyntaxKind.ImplicitArrayCreationExpression);
{
N(SyntaxKind.NewKeyword);
N(SyntaxKind.OpenBracketToken);
N(SyntaxKind.CloseBracketToken);
N(SyntaxKind.ArrayInitializerExpression);
{
N(SyntaxKind.OpenBraceToken);
N(SyntaxKind.NumericLiteralExpression);
{
N(SyntaxKind.NumericLiteralToken, "1");
}
N(SyntaxKind.CommaToken);
N(SyntaxKind.NumericLiteralExpression);
{
N(SyntaxKind.NumericLiteralToken, "2");
}
N(SyntaxKind.CommaToken);
N(SyntaxKind.NumericLiteralExpression);
{
N(SyntaxKind.NumericLiteralToken, "3");
}
N(SyntaxKind.CloseBraceToken);
}
}
N(SyntaxKind.BracketedArgumentList);
{
N(SyntaxKind.OpenBracketToken);
N(SyntaxKind.Argument);
{
N(SyntaxKind.NumericLiteralExpression);
{
N(SyntaxKind.NumericLiteralToken, "2");
}
}
N(SyntaxKind.CloseBracketToken);
}
}
N(SyntaxKind.CloseBraceToken);
}
N(SyntaxKind.InterpolatedStringText);
{
N(SyntaxKind.InterpolatedStringTextToken);
}
N(SyntaxKind.InterpolatedStringEndToken);
}
EOF();

Assert.Equal("Text with ", expr.Contents[0].ToString());
Assert.Equal(" parts and new line expressions!", expr.Contents[2].ToString());
}

[Fact]
public void TestName()
{
Expand Down

0 comments on commit 498d5b1

Please sign in to comment.