This commit is contained in:
Mike Farah 2021-01-16 14:56:52 +11:00
parent f7cfdc29e1
commit c63801a8a5
2 changed files with 20 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -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"}`,