Added test operator

This commit is contained in:
Mike Farah
2021-07-09 15:54:56 +10:00
parent 69c45ff64a
commit b9d01f1e95
5 changed files with 87 additions and 12 deletions
+29
View File
@@ -62,6 +62,35 @@ var stringsOperatorScenarios = []expressionScenario{
"D0, P[], ()::string: cat\noffset: 4\nlength: 3\ncaptures: []\n",
},
},
{
skipDoc: true,
description: "No match",
document: `dog`,
expression: `match("cat"; "g")`,
expected: []string{},
},
{
skipDoc: true,
description: "No match",
expression: `"dog" | match("cat", "g")`,
expected: []string{},
},
{
skipDoc: true,
description: "No match",
expression: `"dog" | match("cat")`,
expected: []string{},
},
{
description: "Test using regex",
subdescription: "Like jq'q equivalant, this works like match but only returns true/false instead of full match details",
document: `["cat", "dog"]`,
expression: `.[] | test("at")`,
expected: []string{
"D0, P[0], (!!bool)::true\n",
"D0, P[1], (!!bool)::false\n",
},
},
{
description: "Substitute / Replace string",
subdescription: "This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)\nNote the use of `|=` to run in context of the current string value.",