Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test from PR 50799 for impl PR 56853 #57752

Merged
merged 8 commits into from
Dec 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,78 @@ void M()
EOF();
}

[Fact]
public void TestInterpolatedStringWithNewLinesInExpression()
{
var text = @"$""Text with {\nnew[] {\n 1, 2, 3 \n}[2]\n}parts and new line expressions!"""
.Replace("\\n", System.Environment.NewLine);
bernd5 marked this conversation as resolved.
Show resolved Hide resolved

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