$ASSERTS

From QB64 Phoenix Edition Wiki
Revision as of 21:39, 18 April 2022 by SMcNeill (talk | contribs) (Created page with "The $ASSERTS metacommand enables debug tests with the _ASSERT macro. {{PageSyntax}} :$ASSERTS :$ASSERTS:CONSOLE {{PageDescription}} * If an error message is passed to the _ASSERT statement, it is displayed in the console window if $ASSERTS:CONSOLE is used. ==Availability== * '''Version 1.4 and up'''. {{PageExamples}} ''Example:'' Adding test checks for parameter inputs in a function. {{CodeStart}} {{Cl|$ASSERTS}}:CONSOLE {{Cl|D...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The $ASSERTS metacommand enables debug tests with the _ASSERT macro.


Syntax

$ASSERTS
$ASSERTS:CONSOLE


Description

  • If an error message is passed to the _ASSERT statement, it is displayed in the console window if $ASSERTS:CONSOLE is used.


Availability

  • Version 1.4 and up.


Examples

Example: Adding test checks for parameter inputs in a function.

$ASSERTS:CONSOLE
 
DO
    a = INT(RND * 10)
    b$ = myFunc$(a)
    PRINT a, , b$
    _LIMIT 3
LOOP UNTIL _KEYHIT
 
FUNCTION myFunc$ (value AS SINGLE)
    _ASSERT value > 0, "Value cannot be zero"
    _ASSERT value <= 10, "Value cannot exceed 10"
 
    IF value > 1 THEN plural$ = "s"
    myFunc$ = STRING$(value, "*") + STR$(value) + " star" + plural$ + " :-)"
END FUNCTION


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link