Browse Source

Add parentheses test for "a + (b == null ? c : d)"

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
b00cf1900c
  1. 21
      ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs

21
ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs

@ -108,6 +108,27 @@ namespace ICSharpCode.NRefactory.CSharp @@ -108,6 +108,27 @@ namespace ICSharpCode.NRefactory.CSharp
Assert.AreEqual("-(-a)", InsertReadable(expr));
}
[Test]
public void AdditionWithConditional()
{
Expression expr = new BinaryOperatorExpression {
Left = new IdentifierExpression("a"),
Operator = BinaryOperatorType.Add,
Right = new ConditionalExpression {
Condition = new BinaryOperatorExpression {
Left = new IdentifierExpression("b"),
Operator = BinaryOperatorType.Equality,
Right = new PrimitiveExpression(null)
},
TrueExpression = new IdentifierExpression("c"),
FalseExpression = new IdentifierExpression("d")
}
};
Assert.AreEqual("a + (b == null ? c : d)", InsertRequired(expr));
Assert.AreEqual("a + ((b == null) ? c : d)", InsertReadable(expr));
}
[Test]
public void TypeTestInConditional()
{

Loading…
Cancel
Save