macro » expects(var,default)
Description
This command serves 2 purposes:
- Performs execution-time assertion that the specified data variable (
var
) is defined.
At the time of execution, if the specified data variable is not defined but adefault
value is, then the specified data variable will be created with the specifieddefault
value. However, nodefault
value is given and the specified data variable is not present, Nexial will issued a FAIL result for this command. The latter scenario is functionally equivalent to base »assertVarPresent(var)
. - As a “marker” for
nexial-project-inspector
to collect the “expectation” of this macro prior to its invocation.
Parameters
- var - the data variable this macro expects to be defined prior to its invocation.
- default - the default value to use if the expected data variable is not defined.
Example
The above use of the expects
command shows one data variable - command-type.link.url
- is expected by the enclosing
macro. Since no default is defined, Nexial will issue a FAIL result if the specified data variable is not defined at
the time of execution. Consequently, the execution of
nexial-project-inspector
would
result the expected data variable and the corresponding description being added to the generated macro documentation,
as depicted below: