Expression syntax
The syntax described here can be applied to assert.expression and setvar.expression keys as well as to the when clause (click here for info about the when clause).
Expressions are strings that can contain scalar values (int, float, string, bool), standard operators and variables. Variable names are not surrounded by a ${...}, they are named as is.
The evaluation of the expression must return an int, a string or a bool (floats are converted to ints).
The supported operators are described here: https://github.com/Knetic/govaluate/blob/master/MANUAL.md
Syntactic rules:
- allowed types are:
float64,int,bool,stringandarrays stringsthat matches date format are converted into afloat64+operator can be used with numbers andstring(concatenation)-,*,/,**and%only work with numbers>>,<<,|,&and^useint64(float64will be converted)-as unary operator works with numbers!works withbool~(bitwise not) works with numbers||,&&work withbool?(ternary true) uses abool, any type and returns the 3rd op ornil:(ternary false) uses any type, any type and returns the 3rd op ornil??(null coalescence) returns the left-side if non-nil otherwise returns the right-side>,<,>=,<=are comparators, both ops must have the same type (number orstring)=~,!~are used for regexp matching, both ops arestrings
strlen(string)substr(string, start, end)random(start, end)which returns an integer betweenstartandend, included
expression: "var1 + 3 > 4 * var2"
expression: "strlen(var3) > 0"
expression: "random(1990, 2020)"