mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-06 02:03:24 +08:00
Fixed bug in alternative op, dont evaluate RHS if LHS is truthy
This commit is contained in:
@@ -85,6 +85,24 @@ var alternativeOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (!!bool)::true\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Update or create - entity exists",
|
||||
subdescription: "This initialises `a` if it's not present",
|
||||
expression: "(.a // (.a = 0)) += 1",
|
||||
document: `a: 1`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::a: 2\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Update or create - entity does not exist",
|
||||
subdescription: "This initialises `a` if it's not present",
|
||||
expression: "(.a // (.a = 0)) += 1",
|
||||
document: `b: camel`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!map)::b: camel\na: 1\n",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestAlternativeOperatorScenarios(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user