mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
thoughts
This commit is contained in:
parent
f7cfdc29e1
commit
c63801a8a5
@ -74,9 +74,10 @@ func multiply(preferences multiplyPreferences) func(d *dataTreeNavigator, lhs *C
|
||||
return nil, err
|
||||
}
|
||||
return mergeObjects(d, newThing, rhs, preferences)
|
||||
} else if lhs.Node.Tag == "!!int" && rhs.Node.Tag == "!!int" {
|
||||
return lhs.CreateChild(nil, &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: "12"}), nil
|
||||
}
|
||||
// else if lhs.Node.Tag == "!!int" && rhs.Node.Tag == "!!int" {
|
||||
// return lhs.CreateChild(nil, &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: "12"}), nil
|
||||
// }
|
||||
return nil, fmt.Errorf("Cannot multiply %v with %v", lhs.Node.Tag, rhs.Node.Tag)
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,14 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// crossfunction:
|
||||
// normal single document, treat each match separately: eval
|
||||
// multiple documents, how do you do things between docs??? eval-all
|
||||
// alternative
|
||||
// collect and filter matches according to doc before running expression
|
||||
// d0a d1a d0b d1b
|
||||
// run it for (d0a d1a) x (d0b d1b) - noting that we dont do (d0a x d1a) nor (d0b d1b)
|
||||
// I think this will work for eval-all correctly then..
|
||||
var multiplyOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
skipDoc: true,
|
||||
@ -13,6 +21,15 @@ var multiplyOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: `a: {also: [1]}`,
|
||||
document2: `b: {also: me}`,
|
||||
expression: `. * {"a" : .b}`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
expression: `{} * {"cat":"dog"}`,
|
||||
|
Loading…
Reference in New Issue
Block a user