Added pipe and length docs, fix pipe precedence

This commit is contained in:
Mike Farah
2020-12-01 17:58:07 +11:00
parent da027f69d7
commit c9dbf04da3
18 changed files with 233 additions and 71 deletions
+31
View File
@@ -0,0 +1,31 @@
package yqlib
import (
"testing"
)
var pipeOperatorScenarios = []expressionScenario{
{
description: "Simple Pipe",
document: `{a: {b: cat}}`,
expression: `.a | .b`,
expected: []string{
"D0, P[a b], (!!str)::cat\n",
},
},
{
description: "Multiple updates",
document: `{a: cow, b: sheep, c: same}`,
expression: `.a = "cat" | .b = "dog"`,
expected: []string{
"D0, P[], (doc)::{a: cat, b: dog, c: same}\n",
},
},
}
func TestPipeOperatorScenarios(t *testing.T) {
for _, tt := range pipeOperatorScenarios {
testScenario(t, &tt)
}
documentScenarios(t, "Pipe", pipeOperatorScenarios)
}