This commit is contained in:
Mike Farah
2020-11-28 10:41:09 +11:00
parent 13679e51e2
commit 3cecb4e383
8 changed files with 135 additions and 53 deletions
+25 -6
View File
@@ -5,6 +5,9 @@ import (
)
var multiplyOperatorScenarios = []expressionScenario{
{
description: "*+ doc",
},
{
skipDoc: true,
document: `{a: {also: [1]}, b: {also: me}}`,
@@ -80,15 +83,15 @@ var multiplyOperatorScenarios = []expressionScenario{
description: "Merge keeps style of LHS",
dontFormatInputForDoc: true,
document: `a: {things: great}
b:
also: "me"
`,
b:
also: "me"
`,
expression: `. * {"a":.b}`,
expected: []string{
`D0, P[], (!!map)::a: {things: great, also: "me"}
b:
also: "me"
`,
b:
also: "me"
`,
},
},
{
@@ -99,6 +102,22 @@ b:
"D0, P[], (!!map)::{a: [3, 4, 5], b: [3, 4, 5]}\n",
},
},
{
skipDoc: true,
document: `{a: [1], b: [2]}`,
expression: `.a *+ .b`,
expected: []string{
"D0, P[a], (!!seq)::[1, 2]\n",
},
},
{
description: "Merge, appending arrays",
document: `{a: {array: [1, 2, animal: dog], value: coconut}, b: {array: [3, 4, animal: cat], value: banana}}`,
expression: `.a *+ .b`,
expected: []string{
"D0, P[a], (!!map)::{array: [1, 2, {animal: dog}, 3, 4, {animal: cat}], value: banana}\n",
},
},
{
description: "Merge to prefix an element",
document: `{a: cat, b: dog}`,