Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / ada / acats / tests / cxf / cxf2a01.a
blob002c59d6c8e5d78fdf57c4519e4c45708544356c
1 -- CXF2A01.A
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.
16 -- DISCLAIMER
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 --*
26 -- OBJECTIVE:
27 -- Check that the binary adding operators for a decimal fixed point type
28 -- return values that are integral multiples of the small of the type.
29 --
30 -- TEST DESCRIPTION:
31 -- The test verifies that decimal addition and subtraction behave as
32 -- expected for types with various digits, delta, and Machine_Radix
33 -- values. Types with the minimum values for Decimal.Max_Digits and
34 -- Decimal.Max_Scale (18) are included.
36 -- Two kinds of checks are performed for each type. In the first check,
37 -- the iteration, operation, and operand counts in the foundation and
38 -- the operation tables in this test are given values such that, when the
39 -- operations loop is complete, each operand will have been added to and
40 -- subtracted from the loop's cumulator variable the same number of times,
41 -- albeit in varying order. Thus, the result returned by the operations
42 -- loop should have the same value as that used to initialize the
43 -- cumulator (in this test, zero).
45 -- In the second check, the same operation (addition for some types and
46 -- subtraction for others) is performed during each loop iteration,
47 -- resulting in a cumulative total which is checked against an expected
48 -- value.
50 -- TEST FILES:
51 -- The following files comprise this test:
53 -- FXF2A00.A
54 -- -> CXF2A01.A
56 -- APPLICABILITY CRITERIA:
57 -- This test is only applicable for a compiler attempting validation
58 -- for the Information Systems Annex.
61 -- CHANGE HISTORY:
62 -- 08 Apr 96 SAIC Prerelease version for ACVC 2.1.
64 --!
66 package CXF2A01_0 is
68 ---=---=---=---=---=---=---=---=---=---=---
70 type Micro is delta 10.0**(-18) digits 18; -- range -0.999999999999999999 ..
71 for Micro'Machine_Radix use 10; -- +0.999999999999999999
73 function Add (Left, Right : Micro) return Micro;
74 function Subtract (Left, Right : Micro) return Micro;
77 type Micro_Optr_Ptr is access function (Left, Right : Micro) return Micro;
79 Micro_Add : Micro_Optr_Ptr := Add'Access;
80 Micro_Sub : Micro_Optr_Ptr := Subtract'Access;
82 ---=---=---=---=---=---=---=---=---=---=---
84 type Money is delta 0.01 digits 11; -- range -999,999,999.99 ..
85 for Money'Machine_Radix use 2; -- +999,999,999.99
87 function Add (Left, Right : Money) return Money;
88 function Subtract (Left, Right : Money) return Money;
91 type Money_Optr_Ptr is access function (Left, Right : Money) return Money;
93 Money_Add : Money_Optr_Ptr := Add'Access;
94 Money_Sub : Money_Optr_Ptr := Subtract'Access;
96 ---=---=---=---=---=---=---=---=---=---=---
98 -- Same as Money, but with Radix 10:
100 type Cash is delta 0.01 digits 11; -- range -999,999,999.99 ..
101 for Cash'Machine_Radix use 10; -- +999,999,999.99
103 function Add (Left, Right : Cash) return Cash;
104 function Subtract (Left, Right : Cash) return Cash;
107 type Cash_Optr_Ptr is access function (Left, Right : Cash) return Cash;
109 Cash_Add : Cash_Optr_Ptr := Add'Access;
110 Cash_Sub : Cash_Optr_Ptr := Subtract'Access;
112 ---=---=---=---=---=---=---=---=---=---=---
114 type Broad is delta 10.0**(-9) digits 18; -- range -999,999,999.999999999 ..
115 for Broad'Machine_Radix use 10; -- +999,999,999.999999999
117 function Add (Left, Right : Broad) return Broad;
118 function Subtract (Left, Right : Broad) return Broad;
121 type Broad_Optr_Ptr is access function (Left, Right : Broad) return Broad;
123 Broad_Add : Broad_Optr_Ptr := Add'Access;
124 Broad_Sub : Broad_Optr_Ptr := Subtract'Access;
126 ---=---=---=---=---=---=---=---=---=---=---
128 end CXF2A01_0;
131 --==================================================================--
134 package body CXF2A01_0 is
136 ---=---=---=---=---=---=---=---=---=---=---
138 function Add (Left, Right : Micro) return Micro is
139 begin
140 return (Left + Right); -- Decimal fixed addition.
141 end Add;
143 function Subtract (Left, Right : Micro) return Micro is
144 begin
145 return (Left - Right); -- Decimal fixed subtraction.
146 end Subtract;
148 ---=---=---=---=---=---=---=---=---=---=---
150 function Add (Left, Right : Money) return Money is
151 begin
152 return (Left + Right); -- Decimal fixed addition.
153 end Add;
155 function Subtract (Left, Right : Money) return Money is
156 begin
157 return (Left - Right); -- Decimal fixed subtraction.
158 end Subtract;
160 ---=---=---=---=---=---=---=---=---=---=---
162 function Add (Left, Right : Cash) return Cash is
163 begin
164 return (Left + Right); -- Decimal fixed addition.
165 end Add;
167 function Subtract (Left, Right : Cash) return Cash is
168 begin
169 return (Left - Right); -- Decimal fixed subtraction.
170 end Subtract;
172 ---=---=---=---=---=---=---=---=---=---=---
174 function Add (Left, Right : Broad) return Broad is
175 begin
176 return (Left + Right); -- Decimal fixed addition.
177 end Add;
179 function Subtract (Left, Right : Broad) return Broad is
180 begin
181 return (Left - Right); -- Decimal fixed subtraction.
182 end Subtract;
184 ---=---=---=---=---=---=---=---=---=---=---
186 end CXF2A01_0;
189 --==================================================================--
192 with FXF2A00;
193 package CXF2A01_0.CXF2A01_1 is
195 ---=---=---=---=---=---=---=---=---=---=---
197 type Micro_Ops is array (FXF2A00.Optr_Range) of Micro_Optr_Ptr;
198 type Micro_Opnds is array (FXF2A00.Opnd_Range) of Micro;
200 Micro_Optr_Table_Cancel : Micro_Ops := ( Micro_Add, Micro_Sub,
201 Micro_Add, Micro_Sub,
202 Micro_Add, Micro_Sub );
204 Micro_Optr_Table_Cumul : Micro_Ops := ( others => Micro_Add );
206 Micro_Opnd_Table_Cancel : Micro_Opnds := ( 0.001025000235111997,
207 0.000000000000000003,
208 0.724902903219925400,
209 0.000459228020000011,
210 0.049832104921096533 );
212 Micro_Opnd_Table_Cumul : Micro_Opnds := ( 0.000002309540000000,
213 0.000000278060000000,
214 0.000000000000070000,
215 0.000010003000000000,
216 0.000000023090000000 );
218 function Test_Micro_Ops is new FXF2A00.Operations_Loop
219 (Decimal_Fixed => Micro,
220 Operator_Ptr => Micro_Optr_Ptr,
221 Operator_Table => Micro_Ops,
222 Operand_Table => Micro_Opnds);
224 ---=---=---=---=---=---=---=---=---=---=---
226 type Money_Ops is array (FXF2A00.Optr_Range) of Money_Optr_Ptr;
227 type Money_Opnds is array (FXF2A00.Opnd_Range) of Money;
229 Money_Optr_Table_Cancel : Money_Ops := ( Money_Add, Money_Add,
230 Money_Sub, Money_Add,
231 Money_Sub, Money_Sub );
233 Money_Optr_Table_Cumul : Money_Ops := ( others => Money_Sub );
235 Money_Opnd_Table_Cancel : Money_Opnds := ( 127.10,
236 5600.44,
237 0.05,
238 189662.78,
239 226900402.99 );
241 Money_Opnd_Table_Cumul : Money_Opnds := ( 17.99,
242 500.41,
243 92.78,
244 0.38,
245 2942.99 );
247 function Test_Money_Ops is new FXF2A00.Operations_Loop
248 (Decimal_Fixed => Money,
249 Operator_Ptr => Money_Optr_Ptr,
250 Operator_Table => Money_Ops,
251 Operand_Table => Money_Opnds);
253 ---=---=---=---=---=---=---=---=---=---=---
255 type Cash_Ops is array (FXF2A00.Optr_Range) of Cash_Optr_Ptr;
256 type Cash_Opnds is array (FXF2A00.Opnd_Range) of Cash;
258 Cash_Optr_Table_Cancel : Cash_Ops := ( Cash_Add, Cash_Add,
259 Cash_Sub, Cash_Add,
260 Cash_Sub, Cash_Sub );
262 Cash_Optr_Table_Cumul : Cash_Ops := ( others => Cash_Add );
264 Cash_Opnd_Table_Cancel : Cash_Opnds := ( 127.10,
265 5600.44,
266 0.05,
267 189662.78,
268 226900402.99 );
270 Cash_Opnd_Table_Cumul : Cash_Opnds := ( 3.33,
271 100056.14,
272 22.87,
273 3901.55,
274 111.21 );
276 function Test_Cash_Ops is new FXF2A00.Operations_Loop
277 (Decimal_Fixed => Cash,
278 Operator_Ptr => Cash_Optr_Ptr,
279 Operator_Table => Cash_Ops,
280 Operand_Table => Cash_Opnds);
282 ---=---=---=---=---=---=---=---=---=---=---
284 type Broad_Ops is array (FXF2A00.Optr_Range) of Broad_Optr_Ptr;
285 type Broad_Opnds is array (FXF2A00.Opnd_Range) of Broad;
287 Broad_Optr_Table_Cancel : Broad_Ops := ( Broad_Sub, Broad_Add,
288 Broad_Add, Broad_Sub,
289 Broad_Sub, Broad_Add );
291 Broad_Optr_Table_Cumul : Broad_Ops := ( others => Broad_Sub );
293 Broad_Opnd_Table_Cancel : Broad_Opnds := ( 1.000009092,
294 732919479.445022293,
295 89662.787000006,
296 660.101010133,
297 1121127.999905594 );
299 Broad_Opnd_Table_Cumul : Broad_Opnds := ( 12.000450223,
300 479.430320780,
301 0.003492096,
302 8.112888400,
303 1002.994937800 );
305 function Test_Broad_Ops is new FXF2A00.Operations_Loop
306 (Decimal_Fixed => Broad,
307 Operator_Ptr => Broad_Optr_Ptr,
308 Operator_Table => Broad_Ops,
309 Operand_Table => Broad_Opnds);
311 ---=---=---=---=---=---=---=---=---=---=---
313 end CXF2A01_0.CXF2A01_1;
316 --==================================================================--
319 with CXF2A01_0.CXF2A01_1;
321 with Report;
322 procedure CXF2A01 is
323 package Data renames CXF2A01_0.CXF2A01_1;
325 use type CXF2A01_0.Micro;
326 use type CXF2A01_0.Money;
327 use type CXF2A01_0.Cash;
328 use type CXF2A01_0.Broad;
330 Micro_Cancel_Expected : constant CXF2A01_0.Micro := 0.0;
331 Money_Cancel_Expected : constant CXF2A01_0.Money := 0.0;
332 Cash_Cancel_Expected : constant CXF2A01_0.Cash := 0.0;
333 Broad_Cancel_Expected : constant CXF2A01_0.Broad := 0.0;
335 Micro_Cumul_Expected : constant CXF2A01_0.Micro := 0.075682140420000000;
336 Money_Cumul_Expected : constant CXF2A01_0.Money := -21327300.00;
337 Cash_Cumul_Expected : constant CXF2A01_0.Cash := 624570600.00;
338 Broad_Cumul_Expected : constant CXF2A01_0.Broad := -9015252.535794000;
340 Micro_Actual : CXF2A01_0.Micro;
341 Money_Actual : CXF2A01_0.Money;
342 Cash_Actual : CXF2A01_0.Cash;
343 Broad_Actual : CXF2A01_0.Broad;
344 begin
346 Report.Test ("CXF2A01", "Check decimal addition and subtraction");
349 ---=---=---=---=---=---=---=---=---=---=---
352 Micro_Actual := Data.Test_Micro_Ops (0.0,
353 Data.Micro_Optr_Table_Cancel,
354 Data.Micro_Opnd_Table_Cancel);
356 if Micro_Actual /= Micro_Cancel_Expected then
357 Report.Failed ("Wrong cancellation result for type Micro");
358 end if;
360 ---=---=---=---=---=---=---
363 Micro_Actual := Data.Test_Micro_Ops (0.0,
364 Data.Micro_Optr_Table_Cumul,
365 Data.Micro_Opnd_Table_Cumul);
367 if Micro_Actual /= Micro_Cumul_Expected then
368 Report.Failed ("Wrong cumulation result for type Micro");
369 end if;
372 ---=---=---=---=---=---=---=---=---=---=---
375 Money_Actual := Data.Test_Money_Ops (0.0,
376 Data.Money_Optr_Table_Cancel,
377 Data.Money_Opnd_Table_Cancel);
379 if Money_Actual /= Money_Cancel_Expected then
380 Report.Failed ("Wrong cancellation result for type Money");
381 end if;
383 ---=---=---=---=---=---=---
386 Money_Actual := Data.Test_Money_Ops (0.0,
387 Data.Money_Optr_Table_Cumul,
388 Data.Money_Opnd_Table_Cumul);
390 if Money_Actual /= Money_Cumul_Expected then
391 Report.Failed ("Wrong cumulation result for type Money");
392 end if;
395 ---=---=---=---=---=---=---=---=---=---=---
398 Cash_Actual := Data.Test_Cash_Ops (0.0,
399 Data.Cash_Optr_Table_Cancel,
400 Data.Cash_Opnd_Table_Cancel);
402 if Cash_Actual /= Cash_Cancel_Expected then
403 Report.Failed ("Wrong cancellation result for type Cash");
404 end if;
407 ---=---=---=---=---=---=---
410 Cash_Actual := Data.Test_Cash_Ops (0.0,
411 Data.Cash_Optr_Table_Cumul,
412 Data.Cash_Opnd_Table_Cumul);
414 if Cash_Actual /= Cash_Cumul_Expected then
415 Report.Failed ("Wrong cumulation result for type Cash");
416 end if;
419 ---=---=---=---=---=---=---=---=---=---=---
422 Broad_Actual := Data.Test_Broad_Ops (0.0,
423 Data.Broad_Optr_Table_Cancel,
424 Data.Broad_Opnd_Table_Cancel);
426 if Broad_Actual /= Broad_Cancel_Expected then
427 Report.Failed ("Wrong cancellation result for type Broad");
428 end if;
431 ---=---=---=---=---=---=---
434 Broad_Actual := Data.Test_Broad_Ops (0.0,
435 Data.Broad_Optr_Table_Cumul,
436 Data.Broad_Opnd_Table_Cumul);
438 if Broad_Actual /= Broad_Cumul_Expected then
439 Report.Failed ("Wrong cumulation result for type Broad");
440 end if;
443 ---=---=---=---=---=---=---=---=---=---=---
446 Report.Result;
448 end CXF2A01;