Skip to content

Commit

Permalink
Add test for array index access
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoraes committed Oct 31, 2024
1 parent 26bff98 commit 80ecd04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions JexlNet.Test/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public async void PassesContextAsync()
Assert.Equal("bar", result?.ToString());
}

[Fact]
public async void AccessIndexOutOfBOunds_ReturnsBoolean()
{
var jexl = new Jexl();
var expr = jexl.CreateExpression("!data[2]");
var result = await expr.EvalAsync(new JsonObject { { "data", new JsonArray() { "foo" } } });
Assert.Equal(System.Text.Json.JsonValueKind.True, result.GetValueKind());
}

public class TestExpression(string exprStr) : Expression(exprStr)
{
public int CompileCallCount { get; private set; }
Expand Down

0 comments on commit 80ecd04

Please sign in to comment.