Assert command: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
__TOC__
__TOC__
{|
{|
|width="50%"| '''Action:'''
|width="125px"| '''Action:'''
|width="50%"|
|width="775px"|
<span class="f_Para">Performs an equality or inequality comparison between a) the value of program data or a [[Working with macro variables|macro variable]] or [[Working with Client functions (Debugger)|Client function]], and b) a constant or the value of a macro variable or macro function. For example: </span>
<span class="f_Para">Performs an equality or inequality comparison between a) the value of program data or a [[Working with macro variables|macro variable]] or [[Working with Client functions (Debugger)|Client function]], and b) a constant or the value of a macro variable or macro function. For example: </span>



Latest revision as of 22:04, 20 January 2023

Action:

Performs an equality or inequality comparison between a) the value of program data or a macro variable or Client function, and b) a constant or the value of a macro variable or macro function. For example:

assert %i==666 

This command lets you create simple testing macros that ensure that key elements in your code have the values you expect. If the comparison expression you construct with assert is not logically true, you receive a failure message. If true, you receive no confirmation.

assert failure messages are displayed in the console, if it is open. Otherwise, they are displayed in a Windows message box. They have the following format:

Assert failed: failing_assert_statement 

For example:

Assert failed: assert &b = "no way" 

The assert command syntax follows:

ASSERT {&var|%x|g.x|f.x|$listcnt(x)|$listinf(x,y)|&&function} {=|==|!=|<>} {string|[-]n|&var|&&function}

where:

  • &var is a previously defined macro variable.
  • %x is a mainframe variable.  

Here are examples of valid assert statements:

assert g.JACK = "No play makes Jack a dull boy."    ASSERt   %s='Hey Moe'  ASSERT $listcnt(%g)= ASSERT $listinf(%g,2) = " makes Jack a dull boy."  assert &this = 'that'  assert &this <> &that  Notes:

  • If you are specifying a Client mapping command and your assertion includes an ampersand character (&) or the not equal operator (<>), you must XML entity encode the character. For example, to map the command assert &i<>6, you specify it like this:

<mapping command="assert &amp;i&lt;&gt;6" button="button9"/>

Client menu: --
Introduced: Build 28