A "symbol" corresponds to a named constant, found in most programming languages.
Every symbol has a type according to Exactly's type system.
The name of a symbol must be unique within the whole test case - symbol names share a global name space.
A symbol name (SYMBOL-NAME) is: A combination of alphanumeric characters and underscores.
A symbol is defined by the "def" instruction:
def string SYMBOL_NAME = "the symbol value"
This defines a symbol SYMBOL_NAME to be the value "the symbol value", which is a value of type string.
The type must be given explicitly.
For example:
def list LIST_SYMBOL = first second "the third"
def text-transformer REPLACE_ID = replace [0-9]{10} ID
A symbol must be defined before it is referenced.
Once defined, a symbol is available to all instructions following the definition - both in the phase where it is defined and in following phases.
A symbol reference may appear in strings and as instruction arguments, in places where an argument of a certain type is expected.
Thus, symbols cannot be used for instruction names or arbitrary instruction arguments (as in unix shell scripts, e.g.).
There are two forms of symbol references:
Plain name | SYMBOL-NAME |
---|
Special syntax | @[SYMBOL-NAME]@ |
---|
The special syntax is designed to reduce the risk of clashes with the syntax of other programming languages and shell script, e.g.
This is important since Exactly has limited capabilities for escaping and quoting.
The special syntax must be used wherever a string value is accepted.
Also, strings that resemble the special syntax will not be considered as errors, since it is assumed that these strings might have the syntax needed for a different purpose.
For example, the following strings does not constitute "symbol" references, and Exactly will not complain:
@[NOT/A_VALID_SYMBOL_NAME]@
@[VALID_SYMBOL_NAME ]@
@[VALID_SYMBOL_NAME]
The plain "symbol" name is used when a "symbol" reference is unambiguous. Otherwise, the special syntax is needed.
For example:
def string S = "reference to @[SYMBOL_NAME]@"
def list L = first @[STRING_SYMBOL]@ "third element"
stdout -transformed-by ( filter LINE_MATCHER_SYMBOL ) ! is-empty
stdout equals -contents-of -rel PATH_SYMBOL @[DIR_NAME_SYMBOL]@/@[BASE_NAME_SYMBOL]@