1 |
294 |
jeremybenn |
-- C57003A.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 |
|
|
-- CHECK THAT THE EXIT STATEMENT IS EVALUATED EACH TIME THROUGH A LOOP,
|
26 |
|
|
-- AND THAT IT IS EVALUATED CORRECTLY WHETHER POSITIONED AT THE
|
27 |
|
|
-- BEGINNING, MIDDLE, OR END OF THE LOOP.
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
-- EACH TEST IS A LOOP ON J WHERE THE EXIT CONDITIONS ARE TO EVALUATE
|
32 |
|
|
-- TO 'FALSE' A CERTAIN NUMBER OF TIMES UNTIL, AT THE APPROPRIATE
|
33 |
|
|
-- TIME, ONE OF THEM EVALUATES TO 'TRUE' AND CAUSES THE LOOP TO BE
|
34 |
|
|
-- EXITED.
|
35 |
|
|
--
|
36 |
|
|
--
|
37 |
|
|
-- THE TEST IS PERFORMED 30 TIMES FOR EACH OF THE FIRST TWO
|
38 |
|
|
-- DATA TYPES CONSIDERED ('INTEGER', USER-DEFINED ENUMERATION)
|
39 |
|
|
-- AND 26 TIMES FOR 'CHARACTER' (THUS 86 TIMES ALTOGETHER).
|
40 |
|
|
--
|
41 |
|
|
--
|
42 |
|
|
-- EACH DATA TYPE HAS ITS OWN SEPARATE SECTION OF CODE. ALL SECTIONS
|
43 |
|
|
-- FOLLOW THE SAME TESTING ALGORITHM (MUTATIS MUTANDIS). THE CALCU-
|
44 |
|
|
-- LATIONS WHICH KEEP TRACK OF THE FLOW OF CONTROL ARE ALL DONE IN
|
45 |
|
|
-- INTEGER ARITHMETIC. THERE ARE THREE DATA TYPES, THUS THREE
|
46 |
|
|
-- SECTIONS.
|
47 |
|
|
--
|
48 |
|
|
--
|
49 |
|
|
-- FOR EACH DATA TYPE, THE 30 TESTS ARE DIVIDED INTO 3 "SEGMENTS"
|
50 |
|
|
--
|
51 |
|
|
-- << NOTE: THE NUMBER OF SEGMENTS IS WRITTEN " 3 " ,
|
52 |
|
|
-- THE NUMBER OF SECTIONS IS WRITTEN "THREE" >>
|
53 |
|
|
--
|
54 |
|
|
-- (OF 10 TESTS EACH, EXCEPT 10,10,6 FOR 'CHARACTER'), NUMBERED
|
55 |
|
|
-- 0 , 1 , 2 AND CORRESPONDING TO THE 3 SIGNIFICANTLY DIFFERENT
|
56 |
|
|
-- POSITIONS OF AN EXIT STATEMENT WITH RESPECT TO THE LOOP IT IS IN
|
57 |
|
|
-- ( "AT THE VERY TOP" , "AT THE VERY BOTTOM" , "ANYWHERE IN BETWEEN"
|
58 |
|
|
-- ). AT THE BEGINNING OF EACH TEST, THE VARIABLE WHICH_SEGMENT
|
59 |
|
|
-- IS UPDATED TO CONTAIN THE NEW VALUE OF THIS IDENTIFYING NUMBER
|
60 |
|
|
-- (FOR THE TEST ABOUT TO BEGIN):
|
61 |
|
|
--
|
62 |
|
|
-- EXIT AT THE TOP ........ WHICH_SEGMENT = 0
|
63 |
|
|
-- EXIT FROM THE MIDDLE ........ WHICH_SEGMENT = 1
|
64 |
|
|
-- EXIT AT THE BOTTOM ........ WHICH_SEGMENT = 2 .
|
65 |
|
|
--
|
66 |
|
|
--
|
67 |
|
|
-- WITHIN EACH SECTION, THE TESTS ARE NUMBERED FROM 1 TO 30
|
68 |
|
|
-- (26 FOR 'CHARACTER'). THIS NUMBER IS STORED IN THE INTEGER
|
69 |
|
|
-- VARIABLE INT_I (EQUAL TO THE CURRENT VALUE OF THE OUTER-LOOP
|
70 |
|
|
-- INDEX WHEN THAT INDEX IS OF INTEGER TYPE), WHOSE APPROPRIATE VALUE
|
71 |
|
|
-- FOR EACH TEST IS SET AT THE BEGINNING OF THE TEST.
|
72 |
|
|
--
|
73 |
|
|
--
|
74 |
|
|
-- AS PART OF THE EVALUATION PROCESS, THE PROGRAM COMPUTES FOR EACH
|
75 |
|
|
-- TEST (I.E. FOR EACH VALUE OF I , OR OF INT_I ) THE APPROPRIATE
|
76 |
|
|
-- NUMBER OF INNER-LOOP ITERATIONS REQUIRED BEFORE EXIT; THIS IS
|
77 |
|
|
-- THE EXPECTED VALUE OF J (EXPRESSED AS AN INTEGER IN THE RANGE
|
78 |
|
|
-- 1..10 ) AND STORES IT IN EXPECTED_J . FOR EACH OF THE THREE
|
79 |
|
|
-- SECTIONS, THE TIME SEQUENCE OF THESE 30 VALUES IS
|
80 |
|
|
--
|
81 |
|
|
-- 1 2 3 4 5 6 7 8 9 10 << SEGMENT 1 >>
|
82 |
|
|
-- 6 6 7 7 8 8 9 9 10 10 << SEGMENT 2 >>
|
83 |
|
|
-- 7 8 8 8 9 9 9 10 10 10 << SEGMENT 3 >>
|
84 |
|
|
--
|
85 |
|
|
-- (EACH SECTION GETS ALL 3 ROWS, NOT ONE ROW PER SECTION;
|
86 |
|
|
-- FOR 'CHARACTER', WHERE ONLY 26 VALUES ARE REQUIRED, THE LAST 4
|
87 |
|
|
-- VALUES ARE OMITTED). THIS NUMBER IS COMPARED WITH THE ACTUAL
|
88 |
|
|
-- VALUE OF J (ACTUAL NUMBER OF INNER-LOOP ITERATIONS BEFORE THE
|
89 |
|
|
-- EXECUTION OF THE EXIT STATEMENT) AS SAVED JUST BEFORE THE EXIT
|
90 |
|
|
-- FROM THE LOOP (AGAIN IN THE FORM OF AN INTEGER IN THE RANGE
|
91 |
|
|
-- 1..30 , IRRESPECTIVE OF THE DATA TYPE BEING TESTED), I F
|
92 |
|
|
-- SUCH SAVED VALUE IS AVAILABLE.
|
93 |
|
|
--
|
94 |
|
|
--
|
95 |
|
|
-- THE ACTUAL VALUE OF INNER-LOOP ITERATIONS (AS SAVED IMMEDIATELY
|
96 |
|
|
-- BEFORE THE EXIT, AS OPPOSED TO A VALUE LEFT OVER FROM SOME
|
97 |
|
|
-- PREVIOUS ITERATION) IS AVAILABLE ONLY IF WHICH_SEGMENT /= 0 ,
|
98 |
|
|
-- AND IS THEN STORED IN SAVE_J .
|
99 |
|
|
--
|
100 |
|
|
--
|
101 |
|
|
-- FOR THE CASE WHICH_SEGMENT = 0 , THE ITERATIONS ARE COUNTED IN
|
102 |
|
|
-- THE VARIABLE COUNT , WHOSE VALUE AT THE COMPLETION OF THE
|
103 |
|
|
-- I-TH TEST ( I IN 1..10 ) MUST BE EQUAL TO EXPECTED_J - 1 ,
|
104 |
|
|
-- AND THUS TO I - 1 (METHODOLOGICALLY AS WELL AS COMPUTATIONALLY
|
105 |
|
|
-- THIS IS NO DIFFERENT FROM USING THE MOST RECENT VALUE OF SAVE_J
|
106 |
|
|
-- WHEN A CURRENT ONE CANNOT BE OBTAINED). AFTER BEING INCREMENTED
|
107 |
|
|
-- BY 1 , COUNT IS CHECKED AGAINST EXPECTED_J .
|
108 |
|
|
--
|
109 |
|
|
--
|
110 |
|
|
-- THIS CONCLUDES THE DESCRIPTION OF THE CASE WHICH_SEGMENT = 0 ,
|
111 |
|
|
-- AND THUS OF THE ALGORITHM. THE ONLY REASON FOR SPLITTING THE
|
112 |
|
|
-- CASE WHICH_SEGMENT /= 0 INTO TWO IS THE DESIRE TO PROVIDE FOR
|
113 |
|
|
-- DISTINCT MESSAGES.
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
-- RM 04/23/81
|
118 |
|
|
-- SPS 3/7/83
|
119 |
|
|
|
120 |
|
|
WITH REPORT;
|
121 |
|
|
PROCEDURE C57003A IS
|
122 |
|
|
|
123 |
|
|
USE REPORT ;
|
124 |
|
|
|
125 |
|
|
BEGIN
|
126 |
|
|
|
127 |
|
|
TEST( "C57003A" , "TEST THAT THE EXIT STATEMENT IS EVALUATED" &
|
128 |
|
|
" EACH TIME THROUGH THE LOOP" );
|
129 |
|
|
|
130 |
|
|
DECLARE
|
131 |
|
|
|
132 |
|
|
WHICH_SEGMENT : INTEGER RANGE 0..2 ; -- BOUNDS ARE TIGHT
|
133 |
|
|
SAVE_J : INTEGER RANGE 1..10 ;
|
134 |
|
|
EXPECTED_J : INTEGER RANGE 1..10 ;
|
135 |
|
|
COUNT : INTEGER RANGE 0..100 := 0 ;
|
136 |
|
|
INT_I : INTEGER RANGE 1..30 ;
|
137 |
|
|
|
138 |
|
|
TYPE ENUM IS ( CHANGE_THE_ORIGIN_FROM_0_TO_1 ,
|
139 |
|
|
|
140 |
|
|
A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 ,
|
141 |
|
|
A11, A12, A13, A14, A15, A16, A17, A18, A19, A20 ,
|
142 |
|
|
A21, A22, A23, A24, A25, A26, A27, A28, A29, A30 );
|
143 |
|
|
|
144 |
|
|
BEGIN
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
--------------------------------------------------------------
|
148 |
|
|
----------------------- INTEGER ----------------------------
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
FOR I IN INTEGER RANGE 1..30 LOOP
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
WHICH_SEGMENT := ( I - 1 ) / 10 ;
|
155 |
|
|
EXPECTED_J := ( I + WHICH_SEGMENT ) /
|
156 |
|
|
( WHICH_SEGMENT + 1 ) ;
|
157 |
|
|
|
158 |
|
|
COUNT := 0 ;
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
FOR J IN INTEGER RANGE 1..10 LOOP
|
162 |
|
|
|
163 |
|
|
-- J NOT SAVED HERE (SO THAT 'EXIT' BE FIRST STMT)
|
164 |
|
|
|
165 |
|
|
EXIT WHEN WHICH_SEGMENT = 0 AND
|
166 |
|
|
1*J >= I ;--COUNT+:=1 ON NXT LINE INSTEAD
|
167 |
|
|
COUNT := COUNT + 1 ;
|
168 |
|
|
|
169 |
|
|
NULL ;
|
170 |
|
|
NULL ;
|
171 |
|
|
NULL ;
|
172 |
|
|
SAVE_J := J ;
|
173 |
|
|
EXIT WHEN WHICH_SEGMENT = 1 AND
|
174 |
|
|
2*J >= I ;
|
175 |
|
|
|
176 |
|
|
NULL ;
|
177 |
|
|
NULL ;
|
178 |
|
|
NULL ;
|
179 |
|
|
SAVE_J := J ;
|
180 |
|
|
EXIT WHEN WHICH_SEGMENT = 2 AND
|
181 |
|
|
3*J >= I ;
|
182 |
|
|
|
183 |
|
|
END LOOP;
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
COUNT := COUNT + 1 ; -- SEE HEADER
|
187 |
|
|
|
188 |
|
|
CASE WHICH_SEGMENT IS
|
189 |
|
|
WHEN 0 =>
|
190 |
|
|
IF COUNT /= EXPECTED_J THEN
|
191 |
|
|
FAILED( "WRONG COUNT; INT, EXIT AT TOP" );
|
192 |
|
|
END IF;
|
193 |
|
|
WHEN 1 => -- WOULD WORK ALSO FOR 0
|
194 |
|
|
IF SAVE_J /= EXPECTED_J THEN
|
195 |
|
|
FAILED( "WRONG COUNT; I,EXIT AT MIDDLE" );
|
196 |
|
|
END IF;
|
197 |
|
|
WHEN 2 =>
|
198 |
|
|
IF SAVE_J /= EXPECTED_J THEN
|
199 |
|
|
FAILED( "WRONG COUNT; I,EXIT AT BOTTOM" );
|
200 |
|
|
END IF;
|
201 |
|
|
END CASE;
|
202 |
|
|
|
203 |
|
|
END LOOP;
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
--------------------------------------------------------------
|
208 |
|
|
---------------------- CHARACTER ---------------------------
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
FOR I IN CHARACTER RANGE 'A'..'Z' LOOP
|
212 |
|
|
|
213 |
|
|
INT_I := CHARACTER'POS(I) - CHARACTER'POS('A') + 1;
|
214 |
|
|
|
215 |
|
|
WHICH_SEGMENT := ( INT_I - 1 ) / 10 ;
|
216 |
|
|
EXPECTED_J := ( INT_I + WHICH_SEGMENT ) /
|
217 |
|
|
( WHICH_SEGMENT + 1 ) ;
|
218 |
|
|
|
219 |
|
|
COUNT := 0 ;
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
FOR J IN CHARACTER RANGE 'A'..'J' LOOP
|
223 |
|
|
|
224 |
|
|
-- J NOT SAVED HERE (SO THAT 'EXIT' BE FIRST STMT)
|
225 |
|
|
|
226 |
|
|
EXIT WHEN WHICH_SEGMENT = 0 AND
|
227 |
|
|
J >= I ; -- COUNT+:=1 ON NXT LINE INSTEAD
|
228 |
|
|
COUNT := COUNT + 1 ;
|
229 |
|
|
|
230 |
|
|
NULL ;
|
231 |
|
|
NULL ;
|
232 |
|
|
NULL ;
|
233 |
|
|
SAVE_J := CHARACTER'POS(J) - CHARACTER'POS('A') + 1;
|
234 |
|
|
EXIT WHEN WHICH_SEGMENT = 1 AND
|
235 |
|
|
2 * SAVE_J >= INT_I ;
|
236 |
|
|
|
237 |
|
|
NULL ;
|
238 |
|
|
NULL ;
|
239 |
|
|
NULL ;
|
240 |
|
|
EXIT WHEN WHICH_SEGMENT = 2 AND
|
241 |
|
|
3 * SAVE_J >= INT_I ;
|
242 |
|
|
|
243 |
|
|
END LOOP;
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
COUNT := COUNT + 1 ;
|
247 |
|
|
|
248 |
|
|
CASE WHICH_SEGMENT IS
|
249 |
|
|
WHEN 0 =>
|
250 |
|
|
IF COUNT /= EXPECTED_J THEN
|
251 |
|
|
FAILED( "WRONG COUNT;CHAR, EXIT AT TOP" );
|
252 |
|
|
END IF;
|
253 |
|
|
WHEN 1 => -- WOULD WORK ALSO FOR 0
|
254 |
|
|
IF SAVE_J /= EXPECTED_J THEN
|
255 |
|
|
FAILED( "WRONG COUNT; C,EXIT AT MIDDLE" );
|
256 |
|
|
END IF;
|
257 |
|
|
WHEN 2 =>
|
258 |
|
|
IF SAVE_J /= EXPECTED_J THEN
|
259 |
|
|
FAILED( "WRONG COUNT; C,EXIT AT BOTTOM" );
|
260 |
|
|
END IF;
|
261 |
|
|
END CASE;
|
262 |
|
|
|
263 |
|
|
END LOOP;
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
--------------------------------------------------------------
|
268 |
|
|
--------------------- ENUMERATION --------------------------
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
FOR I IN ENUM RANGE A1..A30 LOOP
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
INT_I := ENUM'POS(I) ;
|
275 |
|
|
|
276 |
|
|
WHICH_SEGMENT := ( INT_I - 1 ) / 10 ;
|
277 |
|
|
EXPECTED_J := ( INT_I + WHICH_SEGMENT ) /
|
278 |
|
|
( WHICH_SEGMENT + 1 ) ;
|
279 |
|
|
|
280 |
|
|
COUNT := 0 ;
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
FOR J IN ENUM RANGE A1..A10 LOOP
|
284 |
|
|
|
285 |
|
|
-- J NOT SAVED HERE (SO THAT 'EXIT' BE FIRST STMT)
|
286 |
|
|
|
287 |
|
|
EXIT WHEN WHICH_SEGMENT = 0 AND
|
288 |
|
|
J >= I ; -- COUNT+:=1 ON NXT LINE INSTEAD
|
289 |
|
|
COUNT := COUNT + 1 ;
|
290 |
|
|
|
291 |
|
|
NULL ;
|
292 |
|
|
NULL ;
|
293 |
|
|
NULL ;
|
294 |
|
|
SAVE_J := ENUM'POS(J) ;
|
295 |
|
|
EXIT WHEN WHICH_SEGMENT = 1 AND
|
296 |
|
|
2 * SAVE_J >= INT_I ;
|
297 |
|
|
|
298 |
|
|
NULL ;
|
299 |
|
|
NULL ;
|
300 |
|
|
NULL ;
|
301 |
|
|
EXIT WHEN WHICH_SEGMENT = 2 AND
|
302 |
|
|
3 * SAVE_J >= INT_I ;
|
303 |
|
|
|
304 |
|
|
END LOOP;
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
COUNT := COUNT + 1 ;
|
308 |
|
|
|
309 |
|
|
CASE WHICH_SEGMENT IS
|
310 |
|
|
WHEN 0 =>
|
311 |
|
|
IF COUNT /= EXPECTED_J THEN
|
312 |
|
|
FAILED( "WRONG COUNT;ENUM, EXIT AT TOP" );
|
313 |
|
|
END IF;
|
314 |
|
|
WHEN 1 => -- WOULD WORK ALSO FOR 0
|
315 |
|
|
IF SAVE_J /= EXPECTED_J THEN
|
316 |
|
|
FAILED( "WRONG COUNT; E,EXIT AT MIDDLE" );
|
317 |
|
|
END IF;
|
318 |
|
|
WHEN 2 =>
|
319 |
|
|
IF SAVE_J /= EXPECTED_J THEN
|
320 |
|
|
FAILED( "WRONG COUNT; E,EXIT AT BOTTOM" );
|
321 |
|
|
END IF;
|
322 |
|
|
END CASE;
|
323 |
|
|
|
324 |
|
|
END LOOP;
|
325 |
|
|
|
326 |
|
|
--------------------------------------------------------------
|
327 |
|
|
|
328 |
|
|
END ;
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
RESULT ;
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
END C57003A ;
|