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 specified exceptions are raised by the subprograms
28 -- defined in package Ada.Numerics.Generic_Complex_Elementary_Functions
29 -- given the prescribed input parameter values.
32 -- This test checks that specific subprograms defined in the
33 -- package Ada.Numerics.Generic_Complex_Elementary_Functions raise the
34 -- exceptions Argument_Error and Constraint_Error when their input
35 -- parameter value are those specified as causing each exception.
36 -- In the case of Constraint_Error, the exception will be raised in
37 -- each test case, provided that the value of the attribute
38 -- 'Machine_Overflows (for the actual type of package
39 -- Generic_Complex_Type) is True.
41 -- APPLICABILITY CRITERIA:
42 -- This test only applies to implementations supporting the
47 -- 06 Dec 94 SAIC ACVC 2.0
48 -- 16 Nov 95 SAIC Corrected visibility problems for ACVC 2.0.1.
49 -- 29 Sep 96 SAIC Incorporated reviewer comments.
50 -- 02 Jun 98 EDS Replace "_i" with "_One".
53 with Ada
.Numerics
.Generic_Complex_Types
;
54 with Ada
.Numerics
.Generic_Complex_Elementary_Functions
;
60 Report
.Test
("CXG1004", "Check that the specified exceptions are " &
61 "raised by the subprograms defined in package " &
62 "Ada.Numerics.Generic_Complex_Elementary_" &
63 "Functions given the prescribed input " &
69 type Real_Type
is new Float;
71 TC_Overflows
: Boolean := Real_Type
'Machine_Overflows;
73 package Complex_Pack
is
74 new Ada
.Numerics
.Generic_Complex_Types
(Real_Type
);
77 new Ada
.Numerics
.Generic_Complex_Elementary_Functions
(Complex_Pack
);
79 use Ada
.Numerics
, Complex_Pack
, CEF
;
81 Complex_Zero
: constant Complex
:= Compose_From_Cartesian
(0.0, 0.0);
82 Plus_One
: constant Complex
:= Compose_From_Cartesian
(1.0, 0.0);
83 Minus_One
: constant Complex
:= Compose_From_Cartesian
(-1.0, 0.0);
84 Plus_i
: constant Complex
:= Compose_From_Cartesian
(i
);
85 Minus_i
: constant Complex
:= Compose_From_Cartesian
(-i
);
87 Complex_Negative_Real
: constant Complex
:=
88 Compose_From_Cartesian
(-4.0, 2.0);
89 Complex_Negative_Imaginary
: constant Complex
:=
90 Compose_From_Cartesian
(3.0, -5.0);
95 -- This procedure is used in "Exception Raising" calls below in an
96 -- attempt to avoid elimination of the subtest through optimization.
98 procedure No_Optimize
(The_Complex_Number
: Complex
) is
100 Report
.Comment
("No Optimize: Should never be printed " &
101 Integer'Image(Integer(The_Complex_Number
.Im
)));
107 -- Check that the exception Numerics.Argument_Error is raised by the
108 -- exponentiation operator when the value of the left operand is zero,
109 -- and the real component of the exponent (or the exponent itself) is
113 TC_Complex
:= "**"(Left
=> Complex_Zero
, Right
=> Complex_Zero
);
114 Report
.Failed
("Argument_Error not raised by exponentiation " &
115 "operator, left operand = complex zero, right " &
116 "operand = complex zero");
117 No_Optimize
(TC_Complex
);
119 when Argument_Error
=> null; -- OK, expected exception.
121 Report
.Failed
("Incorrect exception raised by exponentiation " &
122 "operator, left operand = complex zero, right " &
123 "operand = complex zero");
127 TC_Complex
:= Complex_Zero
**0.0;
128 Report
.Failed
("Argument_Error not raised by exponentiation " &
129 "operator, left operand = complex zero, right " &
130 "operand = real zero");
131 No_Optimize
(TC_Complex
);
133 when Argument_Error
=> null; -- OK, expected exception.
135 Report
.Failed
("Incorrect exception raised by exponentiation " &
136 "operator, left operand = complex zero, right " &
137 "operand = real zero");
142 TC_Complex
:= "**"(Left
=> 0.0, Right
=> Complex_Zero
);
143 Report
.Failed
("Argument_Error not raised by exponentiation " &
144 "operator, left operand = real zero, right " &
145 "operand = complex zero");
146 No_Optimize
(TC_Complex
);
148 when Argument_Error
=> null; -- OK, expected exception.
150 Report
.Failed
("Incorrect exception raised by exponentiation " &
151 "operator, left operand = real zero, right " &
152 "operand = complex zero");
156 -- Check that the exception Constraint_Error is raised under the
157 -- specified circumstances, provided that
158 -- Complex_Types.Real'Machine_Overflows is True.
162 -- Raised by Log, when the value of the parameter X is zero.
164 TC_Complex
:= Log
(X
=> Complex_Zero
);
165 Report
.Failed
("Constraint_Error not raised when Function " &
166 "Log given parameter value of complex zero");
167 No_Optimize
(TC_Complex
);
169 when Constraint_Error
=> null; -- OK, expected exception.
171 Report
.Failed
("Incorrect exception raised when Function " &
172 "Log given parameter value of complex zero");
175 -- Raised by Cot, when the value of the parameter X is zero.
177 TC_Complex
:= Cot
(X
=> Complex_Zero
);
178 Report
.Failed
("Constraint_Error not raised when Function " &
179 "Cot given parameter value of complex zero");
180 No_Optimize
(TC_Complex
);
182 when Constraint_Error
=> null; -- OK, expected exception.
184 Report
.Failed
("Incorrect exception raised when Function " &
185 "Cot given parameter value of complex zero");
188 -- Raised by Coth, when the value of the parameter X is zero.
190 TC_Complex
:= Coth
(Complex_Zero
);
191 Report
.Failed
("Constraint_Error not raised when Function " &
192 "Coth given parameter value of complex zero");
193 No_Optimize
(TC_Complex
);
195 when Constraint_Error
=> null; -- OK, expected exception.
197 Report
.Failed
("Incorrect exception raised when Function " &
198 "Coth given parameter value of complex zero");
201 -- Raised by the exponentiation operator, when the value of the
202 -- left operand is zero and the real component of the exponent
205 TC_Complex
:= Complex_Zero
**Complex_Negative_Real
;
206 Report
.Failed
("Constraint_Error not raised when the " &
207 "exponentiation operator left operand is " &
208 "complex zero, and the real component of " &
209 "the exponent is negative");
210 No_Optimize
(TC_Complex
);
212 when Constraint_Error
=> null; -- OK, expected exception.
214 Report
.Failed
("Incorrect exception raised when the " &
215 "exponentiation operator left operand is " &
216 "complex zero, and the real component of " &
217 "the exponent is negative");
220 -- Raised by the exponentiation operator, when the value of the
221 -- left operand is zero and the exponent itself (when it is of
222 -- type real) is negative.
224 Negative_Exponent
: constant Real_Type
:= -4.0;
226 TC_Complex
:= Complex_Zero
**Negative_Exponent
;
227 Report
.Failed
("Constraint_Error not raised when the " &
228 "exponentiation operator left operand is " &
229 "complex zero, and the real exponent is " &
231 No_Optimize
(TC_Complex
);
233 when Constraint_Error
=> null; -- OK, expected exception.
235 Report
.Failed
("Incorrect exception raised when the " &
236 "exponentiation operator left operand is " &
237 "complex zero, and the real exponent is " &
241 -- Raised by Arctan, when the value of the parameter is +i.
243 TC_Complex
:= Arctan
(Plus_i
);
244 Report
.Failed
("Constraint_Error not raised when Function " &
245 "Arctan is given parameter value +i");
246 No_Optimize
(TC_Complex
);
248 when Constraint_Error
=> null; -- OK, expected exception.
250 Report
.Failed
("Incorrect exception raised when Function " &
251 "Arctan is given parameter value +i");
254 -- Raised by Arctan, when the value of the parameter is -i.
256 TC_Complex
:= Arctan
(Minus_i
);
257 Report
.Failed
("Constraint_Error not raised when Function " &
258 "Arctan is given parameter value -i");
259 No_Optimize
(TC_Complex
);
261 when Constraint_Error
=> null; -- OK, expected exception.
263 Report
.Failed
("Incorrect exception raised when Function " &
264 "Arctan is given parameter value -i");
267 -- Raised by Arccot, when the value of the parameter is +i.
269 TC_Complex
:= Arccot
(Plus_i
);
270 Report
.Failed
("Constraint_Error not raised when Function " &
271 "Arccot is given parameter value +i");
272 No_Optimize
(TC_Complex
);
274 when Constraint_Error
=> null; -- OK, expected exception.
276 Report
.Failed
("Incorrect exception raised when Function " &
277 "Arccot is given parameter value +i");
280 -- Raised by Arccot, when the value of the parameter is -i.
282 TC_Complex
:= Arccot
(Minus_i
);
283 Report
.Failed
("Constraint_Error not raised when Function " &
284 "Arccot is given parameter value -i");
285 No_Optimize
(TC_Complex
);
287 when Constraint_Error
=> null; -- OK, expected exception.
289 Report
.Failed
("Incorrect exception raised when Function " &
290 "Arccot is given parameter value -i");
293 -- Raised by Arctanh, when the value of the parameter is +1.
295 TC_Complex
:= Arctanh
(Plus_One
);
296 Report
.Failed
("Constraint_Error not raised when Function " &
297 "Arctanh is given parameter value +1");
298 No_Optimize
(TC_Complex
);
300 when Constraint_Error
=> null; -- OK, expected exception.
302 Report
.Failed
("Incorrect exception raised when Function " &
303 "Arctanh is given parameter value +1");
306 -- Raised by Arctanh, when the value of the parameter is -1.
308 TC_Complex
:= Arctanh
(Minus_One
);
309 Report
.Failed
("Constraint_Error not raised when Function " &
310 "Arctanh is given parameter value -1");
311 No_Optimize
(TC_Complex
);
313 when Constraint_Error
=> null; -- OK, expected exception.
315 Report
.Failed
("Incorrect exception raised when Function " &
316 "Arctanh is given parameter value -1");
319 -- Raised by Arccoth, when the value of the parameter is +1.
321 TC_Complex
:= Arccoth
(Plus_One
);
322 Report
.Failed
("Constraint_Error not raised when Function " &
323 "Arccoth is given parameter value +1");
324 No_Optimize
(TC_Complex
);
326 when Constraint_Error
=> null; -- OK, expected exception.
328 Report
.Failed
("Incorrect exception raised when Function " &
329 "Arccoth is given parameter value +1");
332 -- Raised by Arccoth, when the value of the parameter is -1.
334 TC_Complex
:= Arccoth
(Minus_One
);
335 Report
.Failed
("Constraint_Error not raised when Function " &
336 "Arccoth is given parameter value -1");
337 No_Optimize
(TC_Complex
);
339 when Constraint_Error
=> null; -- OK, expected exception.
341 Report
.Failed
("Incorrect exception raised when Function " &
342 "Arccoth is given parameter value -1");
347 ("Attribute Complex_Pack.Real'Machine_Overflows is False; " &
348 "evaluation of the complex elementary functions under " &
349 "specified circumstances was not performed");
355 Report
.Failed
("Unexpected exception raised in Test_Block");