Assert (Compiler Magic Function)

From The Oxygene Language Wiki

Jump to:navigation, search

This is a Language topic
Feel free to add your notes to this topic below.



Assertions produce a type of execution interrupt specially designed for development and debugging of applications. They are NOT designed to be used for live releases (see below).

Syntax:

method assert(boolean expression,'assert description');

If the boolean expression results in False, an assertion interrupt occurs and this shows you the location of the assert.

For example, consider the following code:

class method MainForm.Main;
var
  x: Integer := 5;
begin
  Assert(x < 5, 'assertion test');
end;

When the above code is ran, the following dialog is shown at runtime:

PrismAssertAero.png

Assertion interrupts should not be confused with program exceptions - they are a different animal entirely. As the above screenshot shows, you have the option of ignoring the interrupt entirely or of going into debug mode.


Enabling Assertions

As stated above, you will want to suppress assertions when you deploy your application and this is controlled via project options. You can change if assertions are enabled in the project options by enabling or disabling 'Enable Asserts' there. In practice, you will normally stick to the defaults and build shipping versions using the Release configuration, where Enable Asserts is set to False.

See Also


Oxygene-48.png

Area: Oxygene Language
Compiler version: Oxygene 5

Language GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox