Expressions

<expr>
An expression is one of:
  • operand

    • literal integer (can be used as string) or string (e.g. “LSOA”)

    • variable or property, e.g. myvar or object.property

    • list element reference, e.g. object.property[index]

    • call to sub-test, e.g. myrule(3)

    • parenthesised sub-expression, e.g. (a + b)

    • the keyword fail which evaluates to a string which is the fail message from the most recent failing sub-test. This can be used to compose fail messages in higher level tests.

  • infix operator expression, e.g. a + b or c > d

  • prefix operator with operand parameter, i.e. not, len or marked

Boolean valued expressions which evaluate to true or false:

<expr1> < <expr2>
integer <expr1> is less than integer <expr2>
<expr1> > <expr2>
integer <expr1> is greater than integer <expr2>
<expr1> >= <expr2>
integer <expr1> is greater than or equal to integer <expr2>
<expr1> <= <expr2>
integer <expr1> is less than or equal to integer <expr2>
<expr1> == <expr2>
integer <expr1> is equal to integer <expr2>
<expr1> != <expr2>
integer <expr1> is not equal to integer <expr2>
<expr1> eq <expr2>
string <expr1> is equal to string <expr2>
<expr1> ne <expr2>
string <expr1> is not equal to string <expr2>
<expr1> && <expr2>
Logical “and” of two boolean expressions.
Shortcut behaviour: only evaluate <expr2> if <expr1> is true.
<expr1> || <expr2>
Logical “or” of two boolean expressions.
Shortcut behaviour: only evaluate <expr2> if <expr1> is false.
not <expr>
Invert the truth value of boolean valued <expr>
marked <expr>
Has the cell been marked in this table test?
<test>( <expr> [,<expr> ...] )
Evaluate the named test using the supplied parameters resulting in “true” if the test passes and “false” if it fails.
<src> sourceof <map>
True if the variable named <src> is a source of mapping variable named <map>. Both <src> and <map> must be a string valued expression which is a valid variable name.
A variable is also a source of itself.
<map> mapof <src>
True if variable <map> is a mapping (directly or indirectly) of variable <src>. Both <map> and <src> can be a reference to a variable in a list or a literal string variable name.
A variable is never a map of itself.
qin <query_specification>
True if the current query is a subset of the <query_specification>. This means that a query which matches any subset of the specified variable combinations in any order will cause the operator to evaluate to true.
<query_specification> is a comma separated list of variables or sets of variables. A single variable in the query is specified as a literal string (e.g. "AGE") or as a set of possible variables enclosed by parentheses and separated by commas.
Furthermore each variable literal can be replaced by a parenthesised expression consisting of a literal string followed by sourceof which is an alias for all variables which have that variable as a (direct or indirect) source, including itself, e.g.: ("var_name" sourceof)
Example:
qin ("A", "B"), ("C" sourceof), "E"
If D was a mapping of C then the above expression returns true for all of the following queries:
  • “A”, “C”, “E”

  • “B”, “C”, “E”

  • “A”, “D”, “E”

  • “B”, “D”, “E”

and any subset of any of these, i.e.
  • “A”, “C”

  • “A”, “E”

  • “C”, “E”

  • “B”, “C”

  • “B”, “E”

  • “A”, “D”

  • “D”, “E”

  • “B”, “D”

as well as all of the five univariate queries.
Note that, as mentioned above, the queries will match in any order. So, for example, both:
  • “E”, “A”

  • “B”, “E”, “D”

would also match.

Integer valued expressions:

<expr1> * <expr2>
<expr1> multiplied by <expr2>
<expr1> / <expr2>
<expr1> divided by <expr2>. Note that if <expr1> is less than <expr2> then the result will be zero.
<expr1> % <expr2>
<expr1> modulus <expr2>
<expr1> + <expr2>
Sum of <expr1> and <expr2>
<expr1> - <expr2>
<expr1> minus <expr2>
len <list>
Length of list <list>

Reference expressions which evaluate to an object:

<list>[<index>]
Return item at zero based position <index> in list <list>

String valued expressions:

<expr> & <expr> [& <expr> ...]
Concatenate strings