1 |
12 |
jlechner |
-- CD2A31A.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 THAT WHEN A SIZE SPECIFICATION IS GIVEN FOR AN
|
27 |
|
|
-- INTEGER TYPE, THEN OPERATIONS ON VALUES OF SUCH A TYPE
|
28 |
|
|
-- ARE NOT AFFECTED BY THE REPRESENTATION CLAUSE.
|
29 |
|
|
|
30 |
|
|
-- HISTORY:
|
31 |
|
|
-- JET 08/06/87 CREATED ORIGINAL TEST.
|
32 |
|
|
-- DHH 04/06/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA', CHANGED
|
33 |
|
|
-- SIZE CLAUSE VALUE TO 9, AND ADDED REPRESENTAION
|
34 |
|
|
-- CLAUSE CHECK.
|
35 |
|
|
-- JRL 03/27/92 ELIMINATED REDUNDANT TESTING.
|
36 |
|
|
|
37 |
|
|
WITH REPORT; USE REPORT;
|
38 |
|
|
WITH LENGTH_CHECK; -- CONTAINS A CALL TO 'FAILED'.
|
39 |
|
|
PROCEDURE CD2A31A IS
|
40 |
|
|
|
41 |
|
|
BASIC_SIZE : CONSTANT := 9;
|
42 |
|
|
|
43 |
|
|
TYPE INT IS RANGE -100 .. 100;
|
44 |
|
|
|
45 |
|
|
FOR INT'SIZE USE BASIC_SIZE;
|
46 |
|
|
|
47 |
|
|
I1 : INT := -100;
|
48 |
|
|
I2 : INT := 0;
|
49 |
|
|
I3 : INT := 100;
|
50 |
|
|
|
51 |
|
|
TYPE ARRAY_TYPE IS ARRAY (INTEGER RANGE -1 .. 1) OF INT;
|
52 |
|
|
INTARRAY : ARRAY_TYPE := (-100, 0, 100);
|
53 |
|
|
|
54 |
|
|
TYPE REC_TYPE IS RECORD
|
55 |
|
|
COMPN : INT := -100;
|
56 |
|
|
COMPZ : INT := 0;
|
57 |
|
|
COMPP : INT := 100;
|
58 |
|
|
END RECORD;
|
59 |
|
|
|
60 |
|
|
IREC : REC_TYPE;
|
61 |
|
|
|
62 |
|
|
PROCEDURE CHECK_1 IS NEW LENGTH_CHECK (INT);
|
63 |
|
|
|
64 |
|
|
FUNCTION IDENT (I : INT) RETURN INT IS
|
65 |
|
|
BEGIN
|
66 |
|
|
IF EQUAL (0,0) THEN
|
67 |
|
|
RETURN I;
|
68 |
|
|
ELSE
|
69 |
|
|
RETURN 0;
|
70 |
|
|
END IF;
|
71 |
|
|
END IDENT;
|
72 |
|
|
|
73 |
|
|
PROCEDURE PROC (PIN, PIP : INT;
|
74 |
|
|
PIOZ, PIOP : IN OUT INT;
|
75 |
|
|
POP : OUT INT) IS
|
76 |
|
|
|
77 |
|
|
BEGIN
|
78 |
|
|
IF PIN'SIZE < IDENT_INT (BASIC_SIZE) THEN
|
79 |
|
|
FAILED ("INCORRECT VALUE FOR PIN'SIZE");
|
80 |
|
|
END IF;
|
81 |
|
|
|
82 |
|
|
IF NOT ((PIN < IDENT (0)) AND
|
83 |
|
|
(IDENT (PIP) > IDENT (PIOZ)) AND
|
84 |
|
|
(PIOZ <= IDENT (1)) AND
|
85 |
|
|
(IDENT (100) = PIP)) THEN
|
86 |
|
|
FAILED ("INCORRECT RESULTS FOR RELATIONAL " &
|
87 |
|
|
"OPERATORS - 1");
|
88 |
|
|
END IF;
|
89 |
|
|
|
90 |
|
|
IF NOT (((PIN + PIP) = PIOZ) AND
|
91 |
|
|
((PIP - PIOZ) = PIOP) AND
|
92 |
|
|
((PIOP * PIOZ) = PIOZ) AND
|
93 |
|
|
((PIOZ / PIN) = PIOZ) AND
|
94 |
|
|
((PIN ** 1) = PIN) AND
|
95 |
|
|
((PIN REM 9) = IDENT (-1)) AND
|
96 |
|
|
((PIP MOD 9) = IDENT (1))) THEN
|
97 |
|
|
FAILED ("INCORRECT RESULTS FOR BINARY ARITHMETIC " &
|
98 |
|
|
"OPERATORS - 1");
|
99 |
|
|
END IF;
|
100 |
|
|
|
101 |
|
|
IF INT'VAL (-100) /= IDENT (PIN) OR
|
102 |
|
|
INT'VAL (0) /= IDENT (PIOZ) OR
|
103 |
|
|
INT'VAL (100) /= IDENT (PIOP) THEN
|
104 |
|
|
FAILED ("INCORRECT VALUE FOR INT'VAL - 1");
|
105 |
|
|
END IF;
|
106 |
|
|
|
107 |
|
|
IF INT'PRED (PIOZ) /= IDENT (-1) OR
|
108 |
|
|
INT'PRED (PIP) /= IDENT (99) THEN
|
109 |
|
|
FAILED ("INCORRECT VALUE FOR INT'PRED - 1");
|
110 |
|
|
END IF;
|
111 |
|
|
|
112 |
|
|
IF INT'VALUE ("-100") /= IDENT (PIN) OR
|
113 |
|
|
INT'VALUE ("0") /= IDENT (PIOZ) OR
|
114 |
|
|
INT'VALUE ("100") /= IDENT (PIOP) THEN
|
115 |
|
|
FAILED ("INCORRECT VALUE FOR INT'VALUE - 1");
|
116 |
|
|
END IF;
|
117 |
|
|
|
118 |
|
|
POP := 100;
|
119 |
|
|
|
120 |
|
|
END PROC;
|
121 |
|
|
|
122 |
|
|
BEGIN
|
123 |
|
|
TEST ("CD2A31A", "CHECK THAT WHEN A SIZE SPECIFICATION IS " &
|
124 |
|
|
"GIVEN FOR AN INTEGER TYPE, THEN " &
|
125 |
|
|
"OPERATIONS ON VALUES OF SUCH A TYPE ARE " &
|
126 |
|
|
"NOT AFFECTED BY THE REPRESENTATION CLAUSE");
|
127 |
|
|
|
128 |
|
|
CHECK_1 (I1, 9, "INT");
|
129 |
|
|
PROC (-100, 100, I2, I3, I3);
|
130 |
|
|
|
131 |
|
|
IF INT'SIZE /= IDENT_INT (BASIC_SIZE) THEN
|
132 |
|
|
FAILED ("INCORRECT VALUE FOR INT'SIZE");
|
133 |
|
|
END IF;
|
134 |
|
|
|
135 |
|
|
IF I1'SIZE < IDENT_INT (BASIC_SIZE) THEN
|
136 |
|
|
FAILED ("INCORRECT VALUE FOR I1'SIZE");
|
137 |
|
|
END IF;
|
138 |
|
|
|
139 |
|
|
FOR I IN IDENT (I1) .. IDENT (I3) LOOP
|
140 |
|
|
IF NOT (I IN I1 .. I3) OR
|
141 |
|
|
(I NOT IN IDENT(-100) .. IDENT(100)) THEN
|
142 |
|
|
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP " &
|
143 |
|
|
"OPERATORS - 2");
|
144 |
|
|
END IF;
|
145 |
|
|
END LOOP;
|
146 |
|
|
|
147 |
|
|
IF NOT ((+I1 = I1) AND
|
148 |
|
|
(-I3 = I1) AND
|
149 |
|
|
(ABS I1 = I3)) THEN
|
150 |
|
|
FAILED ("INCORRECT RESULTS FOR UNARY ARITHMETIC " &
|
151 |
|
|
"OPERATORS - 2");
|
152 |
|
|
END IF;
|
153 |
|
|
|
154 |
|
|
IF INT'FIRST /= IDENT (-100) THEN
|
155 |
|
|
FAILED ("INCORRECT VALUE FOR INT'FIRST - 2");
|
156 |
|
|
END IF;
|
157 |
|
|
|
158 |
|
|
IF INT'POS (I1) /= IDENT_INT (-100) OR
|
159 |
|
|
INT'POS (I2) /= IDENT_INT ( 0) OR
|
160 |
|
|
INT'POS (I3) /= IDENT_INT ( 100) THEN
|
161 |
|
|
FAILED ("INCORRECT VALUE FOR INT'POS - 2");
|
162 |
|
|
END IF;
|
163 |
|
|
|
164 |
|
|
IF INT'SUCC (I1) /= IDENT (-99) OR
|
165 |
|
|
INT'SUCC (I2) /= IDENT (1) THEN
|
166 |
|
|
FAILED ("INCORRECT VALUE FOR INT'SUCC - 2");
|
167 |
|
|
END IF;
|
168 |
|
|
|
169 |
|
|
IF INT'IMAGE (I1) /= IDENT_STR ("-100") OR
|
170 |
|
|
INT'IMAGE (I2) /= IDENT_STR (" 0") OR
|
171 |
|
|
INT'IMAGE (I3) /= IDENT_STR (" 100") THEN
|
172 |
|
|
FAILED ("INCORRECT VALUE FOR INT'IMAGE - 2");
|
173 |
|
|
END IF;
|
174 |
|
|
|
175 |
|
|
IF INTARRAY(0)'SIZE < IDENT_INT (BASIC_SIZE) THEN
|
176 |
|
|
FAILED ("INCORRECT VALUE FOR INTARRAY(0)'SIZE");
|
177 |
|
|
END IF;
|
178 |
|
|
|
179 |
|
|
IF NOT ((INTARRAY(-1) < IDENT (0)) AND
|
180 |
|
|
(IDENT (INTARRAY (1)) > IDENT (INTARRAY(0))) AND
|
181 |
|
|
(INTARRAY(0) <= IDENT (0)) AND
|
182 |
|
|
(IDENT (100) = INTARRAY (1))) THEN
|
183 |
|
|
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 3");
|
184 |
|
|
END IF;
|
185 |
|
|
|
186 |
|
|
FOR I IN IDENT (INTARRAY(-1)) .. IDENT (INTARRAY(1)) LOOP
|
187 |
|
|
IF NOT (I IN INTARRAY(-1) .. INTARRAY(1)) OR
|
188 |
|
|
(I NOT IN IDENT(-100) .. IDENT(100)) THEN
|
189 |
|
|
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP " &
|
190 |
|
|
"OPERATORS - 3");
|
191 |
|
|
END IF;
|
192 |
|
|
END LOOP;
|
193 |
|
|
|
194 |
|
|
IF NOT (((INTARRAY(-1) + INTARRAY( 1)) = INTARRAY( 0)) AND
|
195 |
|
|
((INTARRAY( 0) - INTARRAY( 1)) = INTARRAY(-1)) AND
|
196 |
|
|
((INTARRAY( 1) * INTARRAY( 0)) = INTARRAY( 0)) AND
|
197 |
|
|
((INTARRAY( 0) / INTARRAY(-1)) = INTARRAY( 0)) AND
|
198 |
|
|
((INTARRAY(-1) ** 1) = INTARRAY(-1)) AND
|
199 |
|
|
((INTARRAY(-1) REM 9) = IDENT (-1)) AND
|
200 |
|
|
((INTARRAY( 1) MOD 9) = IDENT ( 1))) THEN
|
201 |
|
|
FAILED ("INCORRECT RESULTS FOR BINARY ARITHMETIC " &
|
202 |
|
|
"OPERATORS - 3");
|
203 |
|
|
END IF;
|
204 |
|
|
|
205 |
|
|
IF INT'POS (INTARRAY (-1)) /= IDENT_INT (-100) OR
|
206 |
|
|
INT'POS (INTARRAY ( 0)) /= IDENT_INT ( 0) OR
|
207 |
|
|
INT'POS (INTARRAY ( 1)) /= IDENT_INT ( 100) THEN
|
208 |
|
|
FAILED ("INCORRECT VALUE FOR INT'POS - 3");
|
209 |
|
|
END IF;
|
210 |
|
|
|
211 |
|
|
IF INT'SUCC (INTARRAY (-1)) /= IDENT (-99) OR
|
212 |
|
|
INT'SUCC (INTARRAY ( 0)) /= IDENT (1) THEN
|
213 |
|
|
FAILED ("INCORRECT VALUE FOR INT'SUCC - 3");
|
214 |
|
|
END IF;
|
215 |
|
|
|
216 |
|
|
IF INT'IMAGE (INTARRAY (-1)) /= IDENT_STR ("-100") OR
|
217 |
|
|
INT'IMAGE (INTARRAY ( 0)) /= IDENT_STR (" 0") OR
|
218 |
|
|
INT'IMAGE (INTARRAY ( 1)) /= IDENT_STR (" 100") THEN
|
219 |
|
|
FAILED ("INCORRECT VALUE FOR INT'IMAGE - 3");
|
220 |
|
|
END IF;
|
221 |
|
|
|
222 |
|
|
IF IREC.COMPP'SIZE < IDENT_INT (BASIC_SIZE) THEN
|
223 |
|
|
FAILED ("INCORRECT VALUE FOR IREC.COMPP'SIZE");
|
224 |
|
|
END IF;
|
225 |
|
|
|
226 |
|
|
IF NOT ((IREC.COMPN < IDENT (0)) AND
|
227 |
|
|
(IDENT (IREC.COMPP) > IDENT (IREC.COMPZ)) AND
|
228 |
|
|
(IREC.COMPZ <= IDENT (0)) AND
|
229 |
|
|
(IDENT (100) = IREC.COMPP)) THEN
|
230 |
|
|
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 4");
|
231 |
|
|
END IF;
|
232 |
|
|
|
233 |
|
|
FOR I IN IDENT (IREC.COMPN) .. IDENT (IREC.COMPP) LOOP
|
234 |
|
|
IF NOT (I IN IREC.COMPN .. IREC.COMPP) OR
|
235 |
|
|
(I NOT IN IDENT(-100) .. IDENT(100)) THEN
|
236 |
|
|
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP " &
|
237 |
|
|
"OPERATORS - 4");
|
238 |
|
|
END IF;
|
239 |
|
|
END LOOP;
|
240 |
|
|
|
241 |
|
|
IF NOT ((+IREC.COMPN = IREC.COMPN) AND
|
242 |
|
|
(-IREC.COMPP = IREC.COMPN) AND
|
243 |
|
|
(ABS IREC.COMPN = IREC.COMPP)) THEN
|
244 |
|
|
FAILED ("INCORRECT RESULTS FOR UNARY ARITHMETIC " &
|
245 |
|
|
"OPERATORS - 4");
|
246 |
|
|
END IF;
|
247 |
|
|
|
248 |
|
|
IF INT'VAL (-100) /= IDENT (IREC.COMPN) OR
|
249 |
|
|
INT'VAL ( 0) /= IDENT (IREC.COMPZ) OR
|
250 |
|
|
INT'VAL ( 100) /= IDENT (IREC.COMPP) THEN
|
251 |
|
|
FAILED ("INCORRECT VALUE FOR INT'VAL - 4");
|
252 |
|
|
END IF;
|
253 |
|
|
|
254 |
|
|
IF INT'PRED (IREC.COMPZ) /= IDENT (-1) OR
|
255 |
|
|
INT'PRED (IREC.COMPP) /= IDENT (99) THEN
|
256 |
|
|
FAILED ("INCORRECT VALUE FOR INT'PRED - 4");
|
257 |
|
|
END IF;
|
258 |
|
|
|
259 |
|
|
IF INT'VALUE ("-100") /= IDENT (IREC.COMPN) OR
|
260 |
|
|
INT'VALUE ( "0") /= IDENT (IREC.COMPZ) OR
|
261 |
|
|
INT'VALUE ( "100") /= IDENT (IREC.COMPP) THEN
|
262 |
|
|
FAILED ("INCORRECT VALUE FOR INT'VALUE - 4");
|
263 |
|
|
END IF;
|
264 |
|
|
|
265 |
|
|
RESULT;
|
266 |
|
|
END CD2A31A;
|