This commit is contained in:
Mike Farah
2020-11-18 10:32:30 +11:00
parent 3356061e1e
commit dcacad1e7e
14 changed files with 706 additions and 55 deletions
+14 -9
View File
@@ -13,26 +13,30 @@ var selectOperatorScenarios = []expressionScenario{
"D0, P[0], (!!str)::cat\n",
"D0, P[1], (!!str)::goat\n",
},
}, {
},
{
skipDoc: true,
document: `[hot, fot, dog]`,
expression: `.[] | select(. == "*at")`,
expected: []string{},
}, {
},
{
skipDoc: true,
document: `a: [cat,goat,dog]`,
expression: `.a[] | select(. == "*at")`,
expected: []string{
"D0, P[a 0], (!!str)::cat\n",
"D0, P[a 1], (!!str)::goat\n"},
}, {
description: "Select matching values in map",
},
{
description: "Select and update matching values in map",
document: `a: { things: cat, bob: goat, horse: dog }`,
expression: `.a[] | select(. == "*at")`,
expression: `(.a[] | select(. == "*at")) |= "rabbit"`,
expected: []string{
"D0, P[a things], (!!str)::cat\n",
"D0, P[a bob], (!!str)::goat\n"},
}, {
"D0, P[], (doc)::a: {things: rabbit, bob: rabbit, horse: dog}\n",
},
},
{
skipDoc: true,
document: `a: { things: {include: true}, notMe: {include: false}, andMe: {include: fold} }`,
expression: `.a[] | select(.include)`,
@@ -40,7 +44,8 @@ var selectOperatorScenarios = []expressionScenario{
"D0, P[a things], (!!map)::{include: true}\n",
"D0, P[a andMe], (!!map)::{include: fold}\n",
},
}, {
},
{
skipDoc: true,
document: `[cat,~,dog]`,
expression: `.[] | select(. == ~)`,