DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Ada.Assertions

Assert as a procedure, its check proved (RM 11.4.2).

Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.

Availability and ownership

All of RM 11.4.2. Assert's check is its precondition, so every call is proved and Assertion_Error is never raised; the message form is accepted as Ada has it.

A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.

Import and instantiate

with Ada.Assertions;
import Ada.Assertions;

A Vibe module imports this unit's names with from Ada.Assertions import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.

Contract and lifecycle reading

A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.

API 001

Assertion_Error (declaration) — Declared as Ada declares it; a proved program never raises it, because each Assert's check is proved.

Declared interface:

Assertion_Error : exception;

API 002

Assert (declaration) — Assert that Check holds: the precondition is Check, so each call is proved, as pragma Assert is.

Declared interface:

procedure Assert (Check : Boolean)
  with Global => null, Always_Terminates, Pre => Check;

API 003

Assert (declaration) — The same, with a message Ada would give Assertion_Error; the check is proved, so the message is never shown.

Declared interface:

procedure Assert (Check : Boolean; Message : String)
  with Global => null, Always_Terminates, Pre => Check;