Skip to content

Commit

Permalink
Fix || binary operator
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoraes committed Nov 5, 2024
1 parent 7b4085b commit 7522f0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions JexlNet.Test/Evaluator/Evaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public async void EvaluateExpression_ReturnString(string input, string expected)
[InlineData(@"2 <= 1", false)]
[InlineData(@"""foo"" && 6 >= 6 && 0 + 1 && true", true)]
[InlineData(@"!!'foo'", true)]
[InlineData(@"!!{foo:'a'}.bar || !!{bar:'a'}.baz || !!{tek:'a'}.tek", true)]
public async void EvaluateExpression_ReturnBoolean(string input, bool expected)
{
Evaluator _evaluator = new(new Grammar());
Expand Down
6 changes: 3 additions & 3 deletions JexlNet/Grammar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ public class Grammar
{
JsonNode rightVal = await wrapperFunctions[1]();
if (rightVal != null &&
((rightVal.GetValueKind() == JsonValueKind.String && string.IsNullOrEmpty(rightVal.GetValue<string>())) ||
(rightVal.GetValueKind() == JsonValueKind.Number && rightVal is JsonValue rightValue && rightValue.ToDecimal() == 0) ||
(rightVal.GetValueKind() == JsonValueKind.False))
((rightVal.GetValueKind() == JsonValueKind.String && !string.IsNullOrEmpty(rightVal.GetValue<string>())) ||
(rightVal.GetValueKind() == JsonValueKind.Number && rightVal is JsonValue rightValue && rightValue.ToDecimal() != 0) ||
(rightVal.GetValueKind() == JsonValueKind.True))
)
{
return rightVal;
Expand Down

0 comments on commit 7522f0f

Please sign in to comment.