Skip to content

Commit

Permalink
Fix #286 - does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
sys27 committed Aug 29, 2020
1 parent e50b5e1 commit fea5984
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xFunc.Maths/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ private IExpression Exponentiation(TokenReader tokenReader)
if (@operator == null)
return left;

var right = Exponentiation(tokenReader) ??
var right = LeftUnary(tokenReader) ??
throw new ParseException(Resource.ExponentParseException);

return CreateExponentiation(left, right);
Expand Down
16 changes: 16 additions & 0 deletions xFunc.Tests/ParserTests/ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2192,5 +2192,21 @@ public void ImplicitMulAndPowerVariable()

Assert.Equal(expected, exp);
}

[Fact]
public void PowerWithUnaryMinus()
{
var tokens = Builder()
.Number(2)
.Operation(OperatorToken.Exponentiation)
.Operation(OperatorToken.Minus)
.Number(2)
.Tokens;

var exp = parser.Parse(tokens);
var expected = new Pow(Number.Two, new UnaryMinus(Number.Two));

Assert.Equal(expected, exp);
}
}
}

0 comments on commit fea5984

Please sign in to comment.