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

Allow negative literals in conditions #223

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MonoDevelop.MSBuild.Tests/MSBuildConditionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public void TestParenGrouping ()
[TestCase ("'$(foo)' == '' and ('$(bar)' == '')")] // paren group at end of expression string
[TestCase ("")] // empty expression
[TestCase (" ")] // whitespace only
[TestCase ("'$(foo)' > 1.0")] // decimal literal
[TestCase ("'$(foo)' > -1.0")] // negative decimal literal
public void TestParseNoError (string expressionString)
{
var expression = ExpressionParser.ParseCondition (expressionString, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static ExpressionNode ParseConditionOperand (string buffer, ref int offset, int
int start = offset;

var ch = buffer[start];
if (ch == '.' || char.IsDigit (ch)) {
if (ch == '-' || ch == '.' || char.IsDigit (ch)) {
return ReadArgumentNumber (buffer, ref offset, endOffset, baseOffset, out hasError);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ static ExpressionNode ReadArgumentNumber (string buffer, ref int offset, int end
goto case '0';
case ',': case ')': case ']': case ' ': case '\r': case '\n': case '\t':
return Result (ref offset, out hasError);
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
offset++;
continue;
default:
Expand Down
Loading