Generic ast (#1829)

Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
This commit is contained in:
Mike Farah
2023-10-18 12:11:53 +11:00
committed by GitHub
parent 7430419413
commit 13d1bbb45f
171 changed files with 6402 additions and 2421 deletions
+6 -6
View File
@@ -10,7 +10,7 @@ var selectOperatorScenarios = []expressionScenario{
document: `cat`,
expression: `select(false, true)`,
expected: []string{
"D0, P[], (doc)::cat\n",
"D0, P[], (!!str)::cat\n",
},
},
{
@@ -18,7 +18,7 @@ var selectOperatorScenarios = []expressionScenario{
document: `cat`,
expression: `select(true, false)`,
expected: []string{
"D0, P[], (doc)::cat\n",
"D0, P[], (!!str)::cat\n",
},
},
{
@@ -71,8 +71,8 @@ var selectOperatorScenarios = []expressionScenario{
document2: "b: world",
expression: `select(.a == "hello" or .b == "world")`,
expected: []string{
"D0, P[], (doc)::a: hello\n",
"D0, P[], (doc)::b: world\n",
"D0, P[], (!!map)::a: hello\n",
"D0, P[], (!!map)::b: world\n",
},
},
{
@@ -81,7 +81,7 @@ var selectOperatorScenarios = []expressionScenario{
document: `[{animal: cat, legs: {cool: true}}, {animal: fish}]`,
expression: `(.[] | select(.legs.cool == true).canWalk) = true | (.[] | .alive.things) = "yes"`,
expected: []string{
"D0, P[], (doc)::[{animal: cat, legs: {cool: true}, canWalk: true, alive: {things: yes}}, {animal: fish, alive: {things: yes}}]\n",
"D0, P[], (!!seq)::[{animal: cat, legs: {cool: true}, canWalk: true, alive: {things: yes}}, {animal: fish, alive: {things: yes}}]\n",
},
},
{
@@ -121,7 +121,7 @@ var selectOperatorScenarios = []expressionScenario{
document: `a: { things: cat, bob: goat, horse: dog }`,
expression: `(.a.[] | select(. == "cat" or . == "goat")) |= "rabbit"`,
expected: []string{
"D0, P[], (doc)::a: {things: rabbit, bob: rabbit, horse: dog}\n",
"D0, P[], (!!map)::a: {things: rabbit, bob: rabbit, horse: dog}\n",
},
},
{