3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that the 'Identity attribute returns the unique identity of an
28 -- exception. Check that the Raise_Exception procedure can raise an
29 -- exception that is specified through the use of the 'Identity attribute,
30 -- and that Reraise_Occurrence can re-raise an exception occurrence
31 -- using an exception choice parameter.
34 -- This test uses the capability of the 'Identity attribute, which
35 -- returns the unique identity of an exception, as an Exception_Id
36 -- result. This result is used as an input parameter to the procedure
37 -- Raise_Exception. The exception that results is handled, propagated
38 -- using the Reraise_Occurrence procedure, and handled again.
39 -- The above actions are performed for both a user-defined and a
40 -- predefined exception.
44 -- 06 Dec 94 SAIC ACVC 2.0
45 -- 11 Nov 96 SAIC ACVC 2.1: Modified Propagate_User_Exception.
56 Report
.Test
("CB41001", "Check that the 'Identity attribute returns " &
57 "the unique identity of an exception. Check " &
58 "that the 'Identity attribute is of type " &
59 "Exception_Id. Check that the " &
60 "Raise_Exception procedure can raise an " &
61 "exception that is specified through the " &
62 "use of the 'Identity attribute");
66 Check_Points
: constant := 5;
68 type Check_Point_Array_Type
is array (1..Check_Points
) of Boolean;
70 -- Global array used to track the processing path through the test.
71 TC_Check_Points
: Check_Point_Array_Type
:= (others => False);
73 A_User_Defined_Exception
: Exception;
74 An_Exception_ID
: Ada
.Exceptions
.Exception_Id
:=
75 Ada
.Exceptions
.Null_Id
;
77 procedure Propagate_User_Exception
is
78 Hidden_Exception
: Exception;
80 -- Use the 'Identity function to store the unique identity of a
81 -- user defined exception into a variable of type Exception_Id.
83 An_Exception_ID
:= A_User_Defined_Exception
'Identity;
85 -- Raise this user defined exception using the result of the
86 -- 'Identity attribute.
88 Ada
.Exceptions
.Raise_Exception
(E
=> An_Exception_Id
);
90 Report
.Failed
("User defined exception not raised by " &
91 "procedure Propagate_User_Exception");
94 when Proc_Excpt
: A_User_Defined_Exception
=> -- Expected exception.
97 -- By raising a different exception at this point, the
98 -- information associated with A_User_Defined_Exception must
99 -- be correctly stacked internally.
101 Ada
.Exceptions
.Raise_Exception
(Hidden_Exception
'Identity);
102 Report
.Failed
("Hidden_Exception not raised by " &
103 "procedure Propagate_User_Exception");
106 TC_Check_Points
(1) := True;
108 -- Reraise the original exception, which will be propagated
109 -- outside the scope of this procedure.
111 Ada
.Exceptions
.Reraise_Occurrence
(Proc_Excpt
);
112 Report
.Failed
("User defined exception not reraised");
117 Report
.Failed
("Unexpected exception raised by " &
118 "Procedure Propagate_User_Exception");
119 end Propagate_User_Exception
;
123 User_Exception_Block
:
125 -- Call procedure to raise, handle, and reraise a user defined
127 Propagate_User_Exception
;
129 Report
.Failed
("User defined exception not propagated from " &
130 "procedure Propagate_User_Exception");
133 when A_User_Defined_Exception
=> -- Expected exception.
134 TC_Check_Points
(2) := True;
137 ("Unexpected exception handled in User_Exception_Block");
138 end User_Exception_Block
;
141 Predefined_Exception_Block
:
148 -- Use the 'Identity attribute as an input parameter to the
149 -- Raise_Exception procedure.
151 Ada
.Exceptions
.Raise_Exception
(Constraint_Error
'Identity);
152 Report
.Failed
("Constraint_Error not raised in Inner_Block");
155 when Excpt
: Constraint_Error
=> -- Expected exception.
156 TC_Check_Points
(3) := True;
158 -- Reraise the exception.
159 Ada
.Exceptions
.Reraise_Occurrence
(X
=> Excpt
);
160 Report
.Failed
("Predefined exception not raised from " &
161 "within the exception handler - 1");
163 Report
.Failed
("Incorrect result from attempt to raise " &
164 "Constraint_Error using the 'Identity " &
168 Report
.Failed
("Constraint_Error not reraised in Inner_Block");
171 when Block_Excpt
: Constraint_Error
=> -- Expected exception.
172 TC_Check_Points
(4) := True;
174 -- Reraise the exception in a scope where the exception
175 -- was not originally raised.
177 Ada
.Exceptions
.Reraise_Occurrence
(X
=> Block_Excpt
);
178 Report
.Failed
("Predefined exception not raised from " &
179 "within the exception handler - 2");
182 Report
.Failed
("Incorrect result from attempt to raise " &
183 "Constraint_Error using the 'Identity " &
187 Report
.Failed
("Exception not propagated from Inner_Block");
190 when Constraint_Error
=> -- Expected exception.
191 TC_Check_Points
(5) := True;
193 Report
.Failed
("Unexpected exception handled after second " &
194 "reraise of Constraint_Error");
195 end Predefined_Exception_Block
;
198 -- Verify the processing path taken through the test.
200 for i
in 1..Check_Points
loop
201 if not TC_Check_Points
(i
) then
202 Report
.Failed
("Incorrect processing path taken through test, " &
203 "didn't pass check point #" & Integer'Image(i
));
208 when others => Report
.Failed
("Exception raised in Test_Block");