Skip to content

Assertions

Leon Starr edited this page Sep 5, 2021 · 1 revision

Especially during debugging, but even in production code, assertions make it possible to catch a bug and stop further execution while providing useful diagnostic information.

The form is:

>>> <predicate> "<message>"

From the Building class in an elevator application

>>> /R48/Floor "Building {Name} has no floors"

If the above action is executed by an instance of Building, and there is not at least one related Floor instance, a fatal exception will be thrown along with default diagnostic information.

The default diagnostic information indicates the exact location of the assert statement that triggered the exception and the predicate that failed. The values of any attributes or variables can be supplied between {} brackets. Since they appear between quotes, the variable brackets won’t be confused with action grouping brackets.

Introduction

Model semantics

Flows (as Variables)

Constants and literals

Structure of an activity

Accessing the class model

Data flow


Grammar and parsing notes

Components

Clone this wiki locally