Skip to content

Commit

Permalink
Merge branch 'main' into cmp-strings
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly committed Jun 27, 2024
2 parents 52975c1 + 69215c4 commit 867d64a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
- '1.18'
- '1.19'
- '1.20'
- '1.21'
- '1.22'
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 1 addition & 0 deletions pkg/interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (intr *treeInterpreter) execute(node parsing.ASTNode, value interface{}, fu
}
}
}
// TODO: don't we want to return an error here ?
return nil, nil
case parsing.ASTExpRef:
return func(data interface{}) (interface{}, error) {
Expand Down
25 changes: 25 additions & 0 deletions pkg/interpreter/interpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,31 @@ func TestCanSupportProjectionsWithStructs(t *testing.T) {
assert.Equal([]interface{}{"first", "second", "third"}, result)
}

func TestCompareStrings(t *testing.T) {
assert := assert.New(t)
data := []string{"a", "b", "c"}
{
result, err := search(t, "@[?@ > 'a']", data)
assert.Nil(err)
assert.Equal([]interface{}{"b", "c"}, result)
}
{
result, err := search(t, "@[?@ >= 'b']", data)
assert.Nil(err)
assert.Equal([]interface{}{"b", "c"}, result)
}
{
result, err := search(t, "@[?@ < 'b']", data)
assert.Nil(err)
assert.Equal([]interface{}{"a"}, result)
}
{
result, err := search(t, "@[?@ <= 'b']", data)
assert.Nil(err)
assert.Equal([]interface{}{"a", "b"}, result)
}
}

func TestCanSupportSliceOfStructsWithFunctions(t *testing.T) {
assert := assert.New(t)
data := []scalars{{"a1", "b1"}, {"a2", "b2"}}
Expand Down

0 comments on commit 867d64a

Please sign in to comment.