Multiply, substract with custom types

This commit is contained in:
Mike Farah
2022-01-22 16:12:59 +11:00
parent 50df792e49
commit a6c79f3410
12 changed files with 266 additions and 21 deletions
+27 -2
View File
@@ -146,7 +146,7 @@ var addOperatorScenarios = []expressionScenario{
},
{
description: "Custom types: that are really strings",
subdescription: "when custom tags are encountered, yq will try to decode the underlying type.",
subdescription: "When custom tags are encountered, yq will try to decode the underlying type.",
document: "a: !horse cat\nb: !goat _meow",
expression: `.a += .b`,
expected: []string{
@@ -155,13 +155,38 @@ var addOperatorScenarios = []expressionScenario{
},
{
description: "Custom types: that are really numbers",
subdescription: "when custom tags are encountered, yq will try to decode the underlying type.",
subdescription: "When custom tags are encountered, yq will try to decode the underlying type.",
document: "a: !horse 1.2\nb: !goat 2.3",
expression: `.a += .b`,
expected: []string{
"D0, P[], (doc)::a: !horse 3.5\nb: !goat 2.3\n",
},
},
{
skipDoc: true,
document: "a: !horse 2\nb: !goat 2.3",
expression: `.a += .b`,
expected: []string{
"D0, P[], (doc)::a: !horse 4.3\nb: !goat 2.3\n",
},
},
{
skipDoc: true,
document: "a: 2\nb: !goat 2.3",
expression: `.a += .b`,
expected: []string{
"D0, P[], (doc)::a: 4.3\nb: !goat 2.3\n",
},
},
{
skipDoc: true,
description: "Custom types: that are really ints",
document: "a: !horse 2\nb: !goat 3",
expression: `.a += .b`,
expected: []string{
"D0, P[], (doc)::a: !horse 5\nb: !goat 3\n",
},
},
{
description: "Custom types: that are really arrays",
skipDoc: true,