1-- C44003D.ADA
2
3--                             Grant of Unlimited Rights
4--
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
14--     to do so.
15--
16--                                    DISCLAIMER
17--
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.
24--*
25-- OBJECTIVE:
26--     CHECK FOR CORRECT PRECEDENCE OF PREDEFINED AND OVERLOADED
27--     OPERATIONS ON PREDEFINED TYPE FLOAT, USER-DEFINED TYPES, AND
28--     ONE-DIMENSIONAL ARRAYS WITH COMPONENTS OF TYPE FLOAT.
29
30-- HISTORY:
31--     RJW 10/13/88  CREATED ORIGINAL TEST.
32
33WITH REPORT; USE REPORT;
34PROCEDURE C44003D IS
35
36BEGIN
37     TEST ("C44003D", "CHECK FOR CORRECT PRECEDENCE OF PREDEFINED " &
38                      "AND OVERLOADED OPERATIONS ON PREDEFINED TYPE " &
39                      "FLOAT, USER-DEFINED TYPES, AND ONE-DIMEN" &
40                      "SIONAL ARRAYS WITH COMPONENTS OF TYPE FLOAT");
41
42----- PREDEFINED FLOAT:
43
44     DECLARE
45          F1 : FLOAT := 1.0;
46          F2 : FLOAT := 2.0;
47          F5 : FLOAT := 5.0;
48
49          FUNCTION "OR" (LEFT, RIGHT : FLOAT) RETURN FLOAT IS
50          BEGIN
51               RETURN 4.5;
52          END "OR";
53
54          FUNCTION "<" (LEFT, RIGHT : FLOAT) RETURN FLOAT IS
55          BEGIN
56               RETURN 5.5;
57          END "<";
58
59          FUNCTION "-" (LEFT, RIGHT : FLOAT) RETURN FLOAT IS
60          BEGIN
61               RETURN 6.5;
62          END "-";
63
64          FUNCTION "+" (RIGHT : FLOAT) RETURN FLOAT IS
65          BEGIN
66               RETURN 7.5;
67          END "+";
68
69          FUNCTION "*" (LEFT, RIGHT : FLOAT) RETURN FLOAT IS
70          BEGIN
71               RETURN 8.5;
72          END "*";
73
74          FUNCTION "NOT" (RIGHT : FLOAT) RETURN FLOAT IS
75          BEGIN
76               RETURN 9.5;
77          END "NOT";
78
79     BEGIN
80          IF NOT (-ABS F1 + F2 / F1 + F5 ** 2 =  26.0 AND
81                  F1 > 0.0 AND
82                  - F2 * F2 ** 3 = -8.5) THEN
83               FAILED ("INCORRECT RESULT - 1");
84          END IF;
85
86          IF (F1 OR NOT F2 < F1 - F5 * F5 ** 3) /= 4.5 THEN
87               FAILED ("INCORRECT RESULT - 2");
88          END IF;
89     END;
90
91----- USER-DEFINED TYPE:
92
93     DECLARE
94          TYPE USR IS DIGITS 5;
95
96          F1 : USR := 1.0;
97          F2 : USR := 2.0;
98          F5 : USR := 5.0;
99
100          FUNCTION "AND" (LEFT, RIGHT : USR) RETURN USR IS
101          BEGIN
102               RETURN 4.5;
103          END "AND";
104
105          FUNCTION ">=" (LEFT, RIGHT : USR) RETURN USR IS
106          BEGIN
107               RETURN 5.5;
108          END ">=";
109
110          FUNCTION "+" (LEFT, RIGHT : USR) RETURN USR IS
111          BEGIN
112               RETURN 6.5;
113          END "+";
114
115          FUNCTION "-" (RIGHT : USR) RETURN USR IS
116          BEGIN
117               RETURN 7.5;
118          END "-";
119
120          FUNCTION "/" (LEFT, RIGHT : USR) RETURN USR IS
121          BEGIN
122               RETURN 8.5;
123          END "/";
124
125          FUNCTION "**" (LEFT, RIGHT : USR) RETURN USR IS
126          BEGIN
127               RETURN 9.5;
128          END "**";
129     BEGIN
130          IF +F5 - F2 * F1 ** 2 /= 3.0 OR
131             ABS F1 <= 0.0 OR
132             - F2 * F2 ** 3.0 /= 7.5 THEN
133               FAILED ("INCORRECT RESULT - 3");
134          END IF;
135
136          IF (F1 AND F2 >= F1 + F5 / F5 ** 3) /= 4.5 THEN
137               FAILED ("INCORRECT RESULT - 4");
138          END IF;
139     END;
140
141----- ARRAYS:
142
143     DECLARE
144          TYPE ARR IS ARRAY (INTEGER RANGE <>) OF FLOAT;
145
146          SUBTYPE SARR IS ARR (1 .. 3);
147
148          F1 : SARR := (OTHERS => 1.0);
149          F2 : SARR := (OTHERS => 2.0);
150          F5 : SARR := (OTHERS => 5.0);
151
152          FUNCTION "XOR" (LEFT, RIGHT : ARR) RETURN ARR IS
153          BEGIN
154               RETURN (1 .. 3 => 4.5);
155          END "XOR";
156
157          FUNCTION "<=" (LEFT, RIGHT : ARR) RETURN ARR IS
158          BEGIN
159               RETURN (1 .. 3 => 5.5);
160          END "<=";
161
162          FUNCTION "&" (LEFT, RIGHT : ARR) RETURN ARR IS
163          BEGIN
164               RETURN (1 .. 3 => 6.5);
165          END "&";
166
167          FUNCTION "MOD" (LEFT, RIGHT : ARR) RETURN ARR IS
168          BEGIN
169               RETURN (1 .. 3 => 8.5);
170          END "MOD";
171
172          FUNCTION "ABS" (RIGHT : ARR) RETURN ARR IS
173          BEGIN
174               RETURN (1 .. 3 => 9.5);
175          END "ABS";
176     BEGIN
177          IF (ABS F1 <= F2 & F5 MOD F1 XOR F1) /= (1 .. 3 => 4.5) THEN
178               FAILED ("INCORRECT RESULT - 5");
179          END IF;
180
181          IF (ABS F1 & F2) /= (1 .. 3 => 6.5) OR
182             (F1 MOD F2 <= F5) /= (1 .. 3 => 5.5) THEN
183               FAILED ("INCORRECT RESULT - 6");
184          END IF;
185     END;
186
187     RESULT;
188END C44003D;
189