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 a static expression is legal if its evaluation fails
28 -- no language-defined check other than Overflow_Check. Check that such
29 -- a static expression is legal if it is part of a larger static
30 -- expression, even if its value is outside the base range of the
33 -- Check that if a static expression is part of the right operand of a
34 -- short circuit control form whose value is determined by its left
35 -- operand, it is not evaluated.
37 -- Check that a static expression in a non-static context is evaluated
41 -- The first part of the objective is tested by constructing static
42 -- expressions which involve predefined operations of integer, floating
43 -- point, and fixed point subtypes. Intermediate expressions within the
44 -- static expressions have values outside the base range of the expected
45 -- type. In one case, the extended-range intermediates are compared as
46 -- part of a boolean expression. In the remaining two cases, further
47 -- predefined operations on the intermediates bring the final result
48 -- within the base range. An implementation which compiles these static
49 -- expressions satisfies this portion of the objective. A check is
50 -- performed at run-time to ensure that the static expressions evaluate
51 -- to values within the base range of their respective expected types.
53 -- The second part of the objective is tested by constructing
54 -- short-circuit control forms whose left operands have the values
57 -- (TRUE) or else (...)
58 -- (FALSE) and then (...)
60 -- In both cases the left operand determines the value of the condition.
61 -- In the test each right operand involves a division by zero, which will
62 -- raise Constraint_Error if evaluated. A check is made that no exception
63 -- is raised when each short-circuit control form is evaluated, and that
64 -- the value of the condition is that of the left operand.
66 -- The third part of the objective is tested by evaluating static
67 -- expressions involving many operations in contexts which do not
68 -- require a static expression, and verifying that the exact
69 -- mathematical results are calculated.
73 -- 15 Sep 95 SAIC Initial prerelease version for ACVC 2.1.
74 -- 20 Oct 96 SAIC Modified expressions in C490003_0 to avoid
75 -- the use of universal operands.
82 type My_Flt
is digits System
.Max_Digits
;
84 Flt_Range_Diff
: My_Flt
:= (My_Flt
'Base'Last - My_Flt'Base'First
) -
85 (My_Flt
'Last - My_Flt
'First); -- OK.
88 type My_Fix
is delta 0.125 range -128.0 .. 128.0;
90 Symmetric
: Boolean := (My_Fix
'Base'Last - My_Fix'Base'First
) =
91 (My_Fix
'Base'Last + My_Fix'Base'Last
); -- OK.
94 Center
: constant Integer := Integer'Base'Last -
96 Integer'Base'First) / 2; -- OK.
101 --==================================================================--
107 Zero : constant := 0.0;
108 Pi : constant := Ada.Numerics.Pi;
110 Two_Pi : constant := 2.0 * Pi;
111 Half_Pi : constant := Pi/2.0;
113 Quarter : constant := 90.0;
114 Half : constant := 180.0;
115 Full : constant := 360.0;
117 Deg_To_Rad : constant := Half_Pi/90;
118 Rad_To_Deg : constant := 1.0/Deg_To_Rad;
123 --==================================================================--
132 Report.Test ("C490003", "Check that static expressions failing " &
133 "Overflow_Check are legal if part of a larger static " &
134 "expression. Check that static expressions as right " &
135 "operands of short-circuit control forms are not " &
136 "evaluated if value of control form is determined by " &
137 "left operand. Check that static expressions in non-static " &
138 "contexts are evaluated exactly");
142 -- Static expressions within larger static expressions:
146 if C490003_0.Flt_Range_Diff not in C490003_0.My_Flt'Base'Range then
147 Report
.Failed
("Error evaluating static expression: floating point");
150 if C490003_0
.Symmetric
not in Boolean'Range then
151 Report
.Failed
("Error evaluating static expression: fixed point");
154 if C490003_0
.Center
not in Integer'Base'Range then
155 Report.Failed ("Error evaluating static expression: integer");
160 -- Short-circuit control forms:
168 if not ( (N = 0.0) or else (1.0/N > 0.5) ) then
169 Report.Failed ("Error evaluating OR ELSE");
172 when Constraint_Error =>
173 Report.Failed ("Right side of OR ELSE was evaluated");
175 Report.Failed ("OR ELSE: unexpected exception raised");
179 if (N /= 0.0) and then (1.0/N <= 0.5) then
180 Report.Failed ("Error evaluating AND THEN");
183 when Constraint_Error =>
184 Report.Failed ("Right side of AND THEN was evaluated");
186 Report.Failed ("AND THEN: unexpected exception raised");
193 -- Exact evaluation of static expressions:
200 Left : constant := 6.0 + 0.3125*( (Full*0.375) + (Half/2.4) -
201 ((Quarter + 36.0)/3.0) )/10.0; -- 11.25
202 Right : constant := (Pi/3.0) * 1.2 * (15.0/96.0); -- Pi/16
204 if Deg_To_Rad*Left /= Right then
205 Report.Failed ("Static expressions not evaluated exactly: #1");
208 if ((Pi*Rad_To_Deg)*2.0 + 4.0*Quarter)/16.0 /= Rad_To_Deg*(Pi/4.0) then
209 Report.Failed ("Static expressions not evaluated exactly: #2");