Improvments on expressions, gw tests

This commit is contained in:
Denis Arh
2021-03-30 14:58:04 +02:00
parent 723c361171
commit 597c18fd16
8 changed files with 319 additions and 161 deletions
+5
View File
@@ -213,6 +213,11 @@ func (t Array) Has(k string) bool {
}
}
// Push appends value to array
func (t *Array) Push(v TypedValue) {
t.value = append(t.value, v)
}
// Select is field accessor for *types.Array
//
// Similar to SelectGVal but returns typed values
+6 -2
View File
@@ -3,7 +3,6 @@ package expr
import (
"context"
"fmt"
"github.com/PaesslerAG/gval"
)
@@ -71,7 +70,12 @@ func (e *gvalEval) Eval(ctx context.Context, scope *Vars) (interface{}, error) {
}
func (e *gvalEval) Test(ctx context.Context, scope *Vars) (bool, error) {
return e.evaluable.EvalBool(ctx, scope.Dict())
r, err := e.evaluable(ctx, scope.Dict())
if err != nil {
return false, err
}
return !isEmpty(r), nil
}
func Parser(ll ...gval.Language) gval.Language {