1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
-- C45331A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT FOR FIXED POINT TYPES THE OPERATORS "+" AND "-" PRODUCE
-- CORRECT RESULTS WHEN:
-- (A) A, B, A+B, AND A-B ARE ALL MODEL NUMBERS.
-- (B) A IS A MODEL NUMBER BUT B, A+B, AND A-B ARE NOT.
-- (C) A, B, A+B, AND A-B ARE ALL MODEL NUMBERS WITH DIFFERENT
-- SUBTYPES.
-- CASE A: BASIC TYPES THAT FIT THE CHARACTERISTICS OF DURATION'BASE.
-- WRG 8/27/86
-- KAS 11/14/95 REDUCE EXPECTATION FOR T'SMALL
-- KAS 11/30/95 ONE MORE CHANGE...
-- PWN 02/28/96 CLEANED COMMENTS FOR RELEASE
-- KAS 03/18/96 ELIDED TWO 'SMALL CASES FOR 2.1
WITH REPORT; USE REPORT;
PROCEDURE C45331A IS
TYPE LIKE_DURATION IS DELTA 0.020 RANGE -86_400.0 .. 86_400.0;
-- 'MANTISSA = 23.
SUBTYPE F IS LIKE_DURATION DELTA 0.25 RANGE -1000.0 .. 1000.0;
SUBTYPE ST_F1 IS LIKE_DURATION DELTA 0.5 RANGE -4.0 .. 3.0;
SUBTYPE ST_F2 IS LIKE_DURATION DELTA 1.0 / 16
RANGE -13.0 / 16 .. 5.0 + 1.0 / 16;
BEGIN
TEST ("C45331A", "CHECK THAT FOR FIXED POINT TYPES THE " &
"OPERATORS ""+"" AND ""-"" PRODUCE CORRECT " &
"RESULTS - BASIC TYPES");
-------------------------------------------------------------------
A: DECLARE
SMALL, MAX, MIN, ZERO : F := 0.5;
X : F := 0.0;
BEGIN
-- INITIALIZE "CONSTANTS":
IF EQUAL (3, 3) THEN
SMALL := F'SMALL;
MAX := F'LAST; -- BECAUSE F'LAST < F'LARGE AND F'LAST
-- IS A MODEL NUMBER.
MIN := F'FIRST; -- F'FIRST IS A MODEL NUMBER.
ZERO := 0.0;
END IF;
-- CHECK SMALL + OR - ZERO = SMALL:
IF "+"(LEFT => SMALL, RIGHT => ZERO) /= SMALL OR
0.0 + SMALL /= SMALL THEN
FAILED ("F'SMALL + 0.0 /= F'SMALL");
END IF;
IF "-"(LEFT => SMALL, RIGHT => ZERO) /= SMALL OR
SMALL - 0.0 /= SMALL THEN
FAILED ("F'SMALL - 0.0 /= F'SMALL");
END IF;
-- CHECK MAX + OR - ZERO = MAX:
IF MAX + ZERO /= MAX OR 0.0 + MAX /= MAX THEN
FAILED ("F'LAST + 0.0 /= F'LAST");
END IF;
IF MAX - ZERO /= MAX OR MAX - 0.0 /= MAX THEN
FAILED ("F'LAST - 0.0 /= F'LAST");
END IF;
-- CHECK SMALL - SMALL = 0.0:
IF EQUAL (3, 3) THEN
X := SMALL;
END IF;
IF SMALL - X /= 0.0 OR SMALL - SMALL /= 0.0 OR
F'SMALL - F'SMALL /= 0.0 THEN
FAILED ("F'SMALL - F'SMALL /= 0.0");
END IF;
-- CHECK MAX - MAX = 0.0:
IF EQUAL (3, 3) THEN
X := MAX;
END IF;
IF MAX - X /= 0.0 OR MAX - MAX /= 0.0 OR
F'LAST - F'LAST /= 0.0 THEN
FAILED ("F'LAST - F'LAST /= 0.0");
END IF;
-- CHECK ZERO - MAX = MIN, MIN - MIN = 0.0,
-- AND MIN + MAX = 0.0:
IF EQUAL (3, 3) THEN
X := ZERO - MAX;
END IF;
IF X /= MIN THEN
FAILED ("0.0 - 1000.0 /= -1000.0");
END IF;
IF EQUAL (3, 3) THEN
X := MIN;
END IF;
IF MIN - X /= 0.0 OR MIN - MIN /= 0.0 OR
F'FIRST - F'FIRST /= 0.0 THEN
FAILED ("F'FIRST - F'FIRST /= 0.0");
END IF;
IF MIN + MAX /= 0.0 OR MAX + MIN /= 0.0 OR
F'FIRST + F'LAST /= 0.0 THEN
FAILED ("-1000.0 + 1000.0 /= 0.0");
END IF;
-- CHECK ADDITION AND SUBTRACTION FOR ARBITRARY MID-RANGE
-- NUMBERS:
IF EQUAL (3, 3) THEN
X := 100.75;
END IF;
IF (X + SMALL) /= (SMALL + X) OR
(X + SMALL) > (X + 0.25) THEN -- X + SMALL SB <= X + DELTA
FAILED("X + SMALL DELIVERED BAD RESULT");
END IF;
-- CHECK (MAX - SMALL) + SMALL = MAX:
IF EQUAL (3, 3) THEN
X := MAX - SMALL;
END IF;
IF X + SMALL /= MAX THEN
FAILED("(MAX - SMALL) + SMALL /= MAX");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - A");
END A;
-------------------------------------------------------------------
B: DECLARE
NON_MODEL_CONST : CONSTANT := 2.0 / 3;
NON_MODEL_VAR : F := 0.0;
SMALL, MAX, MIN, ZERO : F := 0.5;
X : F := 0.0;
BEGIN
-- INITIALIZE "CONSTANTS":
IF EQUAL (3, 3) THEN
SMALL := F'SMALL;
MAX := F'LAST; -- BECAUSE F'LAST < F'LARGE AND
-- F'LAST IS A MODEL NUMBER.
MIN := F'FIRST; -- F'FIRST IS A MODEL NUMBER.
ZERO := 0.0;
NON_MODEL_VAR := NON_MODEL_CONST;
END IF;
-- CHECK VALUE OF NON_MODEL_VAR:
IF NON_MODEL_VAR NOT IN 0.5 .. 0.75 THEN
FAILED ("VALUE OF NON_MODEL_VAR NOT IN CORRECT RANGE");
END IF;
-- CHECK NON-MODEL VALUE + OR - ZERO:
IF NON_MODEL_VAR + ZERO NOT IN 0.5 .. 0.75 OR
F'(0.0) + NON_MODEL_CONST NOT IN 0.5 .. 0.75 THEN
FAILED ("(2.0 / 3) + 0.0 NOT IN 0.5 .. 0.75");
END IF;
IF NON_MODEL_VAR - ZERO NOT IN 0.5 .. 0.75 OR
NON_MODEL_CONST - F'(0.0) NOT IN 0.5 .. 0.75 THEN
FAILED ("(2.0 / 3) - 0.0 NOT IN 0.5 .. 0.75");
END IF;
-- CHECK ZERO - NON-MODEL:
IF F'(0.0) - NON_MODEL_CONST NOT IN -0.75 .. -0.5 THEN
FAILED ("0.0 - (2.0 / 3) NOT IN -0.75 .. -0.5");
END IF;
IF F'(1.0) - NON_MODEL_CONST NOT IN 0.25 .. 0.5 THEN
FAILED ("1.0 - (2.0 / 3) NOT IN 0.25 .. 0.5");
END IF;
-- CHECK ADDITION AND SUBTRACTION OF NON-MODEL NEAR MIN AND
-- MAX:
IF MIN + NON_MODEL_VAR NOT IN -999.5 .. -999.25 OR
NON_MODEL_CONST + F'FIRST NOT IN -999.5 .. -999.25 THEN
FAILED ("-1000.0 + (2.0 / 3) NOT IN -999.5 .. -999.25");
END IF;
IF MAX - NON_MODEL_VAR NOT IN 999.25 .. 999.5 OR
F'LAST - NON_MODEL_CONST NOT IN 999.25 .. 999.5 THEN
FAILED ("1000.0 - (2.0 / 3) NOT IN 999.25 .. 999.5");
END IF;
-- CHECK ADDITION AND SUBTRACTION FOR ARBITRARY MID-RANGE
-- MODEL NUMBER WITH NON-MODEL:
IF EQUAL (3, 3) THEN
X := -213.25;
END IF;
IF X + NON_MODEL_CONST NOT IN -212.75 .. -212.5 THEN
FAILED ("-213.25 + (2.0 / 3) NOT IN -212.75 .. -212.5");
END IF;
IF NON_MODEL_VAR - X NOT IN 213.75 .. 214.0 THEN
FAILED ("(2.0 / 3) - (-213.25) NOT IN 213.75 .. 214.0");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - B");
END B;
-------------------------------------------------------------------
C: DECLARE
A_SMALL, A_MAX, A_MIN : ST_F1 := 0.0;
B_SMALL, B_MAX, B_MIN : ST_F2 := 0.0;
X : F;
BEGIN
-- INITIALIZE "CONSTANTS":
IF EQUAL (3, 3) THEN
A_SMALL := ST_F1'SMALL;
A_MAX := ST_F1'LAST; -- BECAUSE 'LAST < 'LARGE AND
-- 'LAST IS A MODEL NUMBER.
A_MIN := ST_F1'FIRST; -- 'FIRST IS A MODEL NUMBER.
B_SMALL := ST_F2'SMALL;
B_MAX := ST_F2'LAST; -- BECAUSE 'LAST <= 'LARGE AND
-- 'LAST IS A MODEL NUMBER.
B_MIN := ST_F2'FIRST; -- 'FIRST IS A MODEL NUMBER.
END IF;
IF A_MIN + B_MIN /= -4.8125 THEN
FAILED ("-4.0 + (-0.8125) /= -4.8125");
END IF;
IF A_MIN - B_MIN /= -3.1875 THEN
FAILED ("-4.0 - (-0.8125) /= -3.1875");
END IF;
IF (A_MIN + B_SMALL) NOT IN A_MIN .. -3.9375 THEN
FAILED ("(A_MIN + B_SMALL) NOT IN A_MIN .. -3.9375");
END IF;
IF (A_MIN - B_SMALL) NOT IN -4.0625 .. -4.0 THEN
FAILED ("(A_MIN - B_SMALL) NOT IN -4.0 .. -4.0625");
END IF;
IF A_MIN + B_MAX /= 1.0625 THEN
FAILED ("-4.0 + 5.0625 /= 1.0625");
END IF;
IF A_MIN - B_MAX /= -9.0625 THEN
FAILED ("-4.0 - 5.0625 /= -9.0625");
END IF;
IF (A_SMALL + B_MIN) NOT IN B_MIN..-0.3125 THEN
FAILED ("(A_SMALL + B_MIN) NOT IN B_MIN..-0.3125");
END IF;
IF (A_SMALL - B_MIN) NOT IN +0.8125 .. 1.3125 THEN
FAILED ("(A_SMALL - B_MIN) NOT IN -0.8125 .. 1.3125");
END IF;
IF (A_SMALL + B_MAX) NOT IN 5.0625 .. 5.5625 THEN
FAILED ("(A_SMALL + B_MAX) NOT IN 5.0625 .. 5.5625");
END IF;
IF (A_SMALL - B_MAX) NOT IN -5.0625 .. -4.5625 THEN
FAILED ("(A_SMALL - B_MAX) NOT IN -5.0625 .. -4.5625");
END IF;
IF A_MAX + B_MIN /= 2.1875 THEN
FAILED ("3.0 + (-0.8125) /= 2.1875");
END IF;
IF A_MAX - B_MIN /= 3.8125 THEN
FAILED ("3.0 - (-0.8125) /= 3.8125");
END IF;
IF (A_MAX + B_SMALL) NOT IN 3.0 .. 3.0625 THEN
FAILED ("(A_MAX + B_SMALL) NOT IN 3.0 .. 3.0625");
END IF;
IF (A_MAX - B_SMALL) NOT IN 2.9375..3.0 THEN
FAILED ("(A_MAX - B_SMALL) NOT IN 2.9375..3.0");
END IF;
IF A_MAX + B_MAX /= 8.0625 THEN
FAILED ("3.0 + 5.0625 /= 8.0625");
END IF;
IF A_MAX - B_MAX /= -2.0625 THEN
FAILED ("3.0 - 5.0625 /= -2.0625");
END IF;
X := B_MIN - A_MIN;
IF X NOT IN 3.0 .. 3.25 THEN
FAILED ("-0.8125 - (-4.0) NOT IN RANGE");
END IF;
X := B_MIN - A_SMALL;
IF X NOT IN -1.3125 .. -0.8125 THEN
FAILED ("B_MIN - A_SMALL NOT IN RANGE");
END IF;
X := B_MIN - A_MAX;
IF X NOT IN -4.0 .. -3.75 THEN
FAILED ("-0.8125 - 3.0 NOT IN RANGE");
END IF;
X := B_SMALL - A_MIN;
IF X NOT IN 4.0 .. 4.0625 THEN
FAILED ("B_SMALL - A_MIN NOT IN RANGE");
END IF;
X := B_SMALL - A_MAX;
IF X NOT IN -3.0 .. -2.75 THEN
FAILED ("B_SMALL - A_MAX NOT IN RANGE");
END IF;
X := B_MAX - A_MIN;
IF X NOT IN 9.0 .. 9.25 THEN
FAILED ("5.0625 - (-4.0) NOT IN RANGE");
END IF;
X := B_MAX - A_SMALL;
IF X NOT IN 4.56 .. 5.0625 THEN
FAILED ("5.0625 - 0.5 NOT IN RANGE");
END IF;
X := B_MAX - A_MAX;
IF X NOT IN 2.0 .. 2.25 THEN
FAILED ("5.0625 - 3.0 NOT IN RANGE");
END IF;
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - C");
END C;
-------------------------------------------------------------------
RESULT;
END C45331A;
|