Improved error message

This commit is contained in:
Mike Farah
2021-12-05 10:58:26 +11:00
parent d0fda699e4
commit 8b04d972f3
5 changed files with 78 additions and 3 deletions
+17
View File
@@ -11,6 +11,23 @@ var sortByOperatorScenarios = []expressionScenario{
"D0, P[], (!!seq)::[{a: apple}, {a: banana}, {a: cat}]\n",
},
},
{
description: "Sort array in place",
document: "cool: [{a: banana},{a: cat},{a: apple}]",
expression: `.cool |= sort_by(.a)`,
expected: []string{
"D0, P[], (doc)::cool: [{a: apple}, {a: banana}, {a: cat}]\n",
},
},
{
description: "Sort array of objects by key",
subdescription: "Note that you can give sort_by complex expressions, not just paths",
document: "cool: [{b: banana},{a: banana},{c: banana}]",
expression: `.cool |= sort_by(keys | .[0])`,
expected: []string{
"D0, P[], (doc)::cool: [{a: banana}, {b: banana}, {c: banana}]\n",
},
},
{
description: "Sort is stable",
subdescription: "Note the order of the elements in unchanged when equal in sorting.",