ExpressionParser
ExpressionParser copied to clipboard
Unary minus after parenthesis
The expression "(-50)" is not correctly handled.
DetermineOperatorType does not detect that - after an ExpressionTokenType.OpenParenthesis is a unary minus and not binary minus.
So HandleOperator will treat it as a binary number which fails as there is only a single operand.
[TestMethod]
public void Handle_Unary_Minus_Inside_Parentheses()
{
GivenInput("(-50)");
ExpectResult("-50");
}
A workaround is avoid unary minus directly after a parenthesis by using "(0+-50)"