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,33 @@ void M()
EOF();
}

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

var expr = this.ParseExpression(text);

if (expr is InterpolatedStringExpressionSyntax intStr)
bernd5 marked this conversation as resolved.
Show resolved Hide resolved
{
Assert.Equal(3, intStr.Contents.Count);

Assert.IsType<InterpolatedStringTextSyntax>(intStr.Contents[0]);
Assert.IsType<InterpolationSyntax>(intStr.Contents[1]);
Assert.IsType<InterpolatedStringTextSyntax>(intStr.Contents[0]);

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

Assert.IsType<ElementAccessExpressionSyntax>(((InterpolationSyntax)intStr.Contents[1]).Expression);
}
else
{
Assert.True(false, "Invalid expression type returned");
}
}

[Fact]
public void TestName()
{
Expand Down