Skip to content

Commit

Permalink
Add test "TestInterpolatedStringWithNewLinesInExpression()" which was…
Browse files Browse the repository at this point in the history
… implemented as part of dotnet#50799 and later realized via dotnet#56853
  • Loading branch information
bernd5 committed Nov 13, 2021
1 parent a4d1d8f commit f378dbe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 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,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);

var expr = this.ParseExpression(text);

if (expr is InterpolatedStringExpressionSyntax intStr)
{
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

0 comments on commit f378dbe

Please sign in to comment.