This commit is contained in:
Mike Farah
2020-11-20 14:35:34 +11:00
parent c08980e70f
commit bc87aca8d7
4 changed files with 184 additions and 5 deletions
+25 -5
View File
@@ -6,18 +6,37 @@ import (
var booleanOperatorScenarios = []expressionScenario{
{
document: `{}`,
expression: `true or false`,
description: "OR example",
expression: `true or false`,
expected: []string{
"D0, P[], (!!bool)::true\n",
},
}, {
document: `{}`,
},
{
description: "AND example",
expression: `true and false`,
expected: []string{
"D0, P[], (!!bool)::false\n",
},
},
{
document: "[{a: bird, b: dog}, {a: frog, b: bird}, {a: cat, b: fly}]",
description: "Matching nodes with select, equals and or",
expression: `.[] | select(.a == "cat" or .b == "dog")`,
expected: []string{
"D0, P[], (!!map)::{a: bird, b: dog}\n",
"D0, P[], (!!map)::{a: cat, b: fly}\n",
},
},
{
skipDoc: true,
expression: `false or false`,
expected: []string{
"D0, P[], (!!bool)::false\n",
},
}, {
},
{
skipDoc: true,
document: `{a: true, b: false}`,
expression: `.[] or (false, true)`,
expected: []string{
@@ -33,4 +52,5 @@ func TestBooleanOperatorScenarios(t *testing.T) {
for _, tt := range booleanOperatorScenarios {
testScenario(t, &tt)
}
documentScenarios(t, "Boolean Operators", assignOperatorScenarios)
}