Skip to content

Macros & Expressions

Ioannis Charalampidis edited this page May 11, 2016 · 4 revisions

roBob supports macros in order to template the creation of specification files. A typical macro has the following format and can appear anywhere in your specification file:

${property}

A property name can only contain alphanumerical characters and the symbols . and _. Anything else will be considered an expression and will lead into unexpected problems.

Property Namespaces

Properties are grouped in different namespaces:

  • app. - Current application properties
  • app.[name]. - Specific application properties
  • node. - Current node properties
  • node.[name]. - Specific node properties
  • parser. - Current parser properties
  • parser.[name]. - Specific parser properties
  • stream. - Current stream properties
  • stream.[name]. - Specific stream properties
  • metric.[name]. - Specific metric properties
  • report. - Report properties
  • curr. - Current values of the test-case parameters

In addition, the following properties are automatically exposed in the global namespace:

  • All properties in the global section
  • The current values of the test-case
  • Properties defined in a define section in an app, stream, or parser

Default Values

You can also specify a default value when evaluating a macro. To do so, you can use the | character:

${property.name|default_value}

Expressions

You can also evaluate simple expressions inside a macro. An expression is considered a macro that contains any character of the following: ()+-/*^%. For example:

${property.name * another.property}
${property.size / 4}
${first.property + second.property / (third.property * fourth.property)}

The following functions are also available: str(), int(), float(), round() and pow().

Clone this wiki locally