Moved eval function to eval interface

This commit is contained in:
Mike Farah
2021-02-11 10:58:40 +11:00
parent e6336bcb85
commit ba223df4ac
3 changed files with 25 additions and 26 deletions
-39
View File
@@ -1,39 +0,0 @@
package yqlib
import (
"testing"
"github.com/mikefarah/yq/v4/test"
)
var evaluateNodesScenario = []expressionScenario{
{
document: `a: hello`,
expression: `.a`,
expected: []string{
"D0, P[a], (!!str)::hello\n",
},
},
{
document: `a: hello`,
expression: `.`,
expected: []string{
"D0, P[], (doc)::a: hello\n",
},
},
{
document: `- a: "yes"`,
expression: `.[] | has("a")`,
expected: []string{
"D0, P[0], (!!bool)::true\n",
},
},
}
func TestEvaluateNodesScenarios(t *testing.T) {
for _, tt := range evaluateNodesScenario {
node := test.ParseData(tt.document)
list, _ := EvaluateNodes(tt.expression, &node)
test.AssertResultComplex(t, tt.expected, resultsToString(list))
}
}