Your action arguments may contain numeric operations, such as addition and division.
Such operations can operate on both numeric literals as well as variables.
In the My
expressions test module you created
previously, create a new test case:
Place your cell pointer on a line somewhere below the existing set of
action lines (but before the FINAL section, if any).
Click Create New Test Case
on the toolbar.
A test case line similar to the following is inserted.
In the second column of the new line, assign the test
case an ID of TC 02 (if not already set to that
Press Tab to
advance to the next column, and provide a description for your test
case, such as numeric ops.
Add the following two report action lines to your test
report # 20 + 10 * 5
report # (20 + 10) * 5
If you are familiar with operator precedence, you know that these two
expressions are evaluated differently. In the first action line, the
multiplication is performed first, then the addition. The second expression
makes use of parentheses to force the addition to be performed first.
Add two more action lines, to create and set two local variables:
local variable x 4
local variable y # 20 + 10 * 5
Note: A variable may be set to a numeric value as well as a string, with no need to
explicitly declare the variable's data type. Also notice that the
value argument in a local
variable action line can hold an expression as well as a
Tip: During an editing session, entering the # symbol in
an empty argument cell triggers an autocomplete pop-up window containing a list of variables
thought to be within scope at that position in the action lines. Use the
Up and Down arrow keys to select one, should you
need it inserted at that point. You can bring back the pop-up list at any further point in the
expression by pressing Ctrl + Space
Finally, add a report action line:
report # x * y
In this case, the expression involved consists of an operation on
variables, rather than constants.
Your test case should now resemble this:
Execute Test Case 02 of your test.
With your test displayed in the editor, do the
The status bar (at the bottom left of the
TestArchitect window) indicates the stages of the test as it progresses.
The Execute Test dialog box appears.
In the Test Modules panel, expand the
Ensure that only the check box for
test case TC 02 is
As expected, the expressions in rows 32 and 33 yield different results, due to a
differing order of operations. Line 40 displays the result of an expression involving