411 REFERENCE · Wikibooks
Ada Programming/Libraries/Ada.Assertions
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Ada.Assertions
__TOC__
Ada Assertions is a unit of the Predefined Language Environment since Ada 2005.
The Assert procedures in this package raise the Assertion_Error exception if the Check parameter is False.
This is the same behavior as the Assert when the Assertion_Policy is Check. In fact, you could think of Assert as a call to this package, conditioned to the value of the Assertion_Policy.
Example
This will raise Assertion_Error with the provided message.
with Ada.Assertions;
procedure Failing_Assertion is
begin
Ada.Assertions.Assert (0 in Positive, "0 is not in the positive range");
end Failing_Assertion;
Specification
Standard Ada library specification
Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>
Copyright (c) 2004-2016 AXE Consultants
Copyright (c) 2004, 2005, 2006 Ada-Europe
Copyright (c) 2000 The MITRE Corporation, Inc.
Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
-------------------------------------------------------------------------
package Ada Assertions is
pragma Pure (Assertions);
Assertion_Error : exception;
procedure Assert (Check : in Boolean);
procedure Assert (Check : in Boolean; Message : in String);
end Adadot .Assertions;
See also
Wikibook
Ada Programming/Libraries/Ada
Ada Programming/Contract Based Programming
Ada Reference Manual
Ada 2005
11 4 2 Pragmas Assert and Assertion_Policy
Ada 2012
11 4 2 Pragmas Assert and Assertion_Policy
Open-Source Implementations
a-assert.ads a-assert.adb
a-assert.ads a-assert.adb