annotate gcc/testsuite/ada/acats/tests/cxb/cxb4006.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CXB4006.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that the function Valid with Packed_Decimal and Packed_Format
kono
parents:
diff changeset
28 -- parameters returns True if Item (the Packed_Decimal parameter) has
kono
parents:
diff changeset
29 -- a value consistent with the Packed_Format parameter.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- Check that the function Length with Packed_Format parameter returns
kono
parents:
diff changeset
32 -- the minimal length of a Packed_Decimal value sufficient to hold any
kono
parents:
diff changeset
33 -- value of type Num when represented according to parameter Format.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Check that the function To_Decimal with Packed_Decimal and
kono
parents:
diff changeset
36 -- Packed_Format parameters produces a decimal type value corresponding
kono
parents:
diff changeset
37 -- to the Packed_Decimal parameter value Item, under the conditions of
kono
parents:
diff changeset
38 -- the Packed_Format parameter Format.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 -- Check that the function To_Packed with Decimal (Num) and
kono
parents:
diff changeset
41 -- Packed_Format parameters produces a Packed_Decimal result that
kono
parents:
diff changeset
42 -- corresponds to the decimal parameter under conditions of the
kono
parents:
diff changeset
43 -- Packed_Format parameter.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- Check that Conversion_Error is propagated by function To_Packed if
kono
parents:
diff changeset
46 -- the value of the decimal parameter Item is negative and the specified
kono
parents:
diff changeset
47 -- Packed_Format parameter is Packed_Unsigned.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 -- TEST DESCRIPTION:
kono
parents:
diff changeset
51 -- This test checks the results from instantiated versions of
kono
parents:
diff changeset
52 -- several functions that deal with parameters or results of type
kono
parents:
diff changeset
53 -- Packed_Decimal. Since the rules for the formation of Packed_Decimal
kono
parents:
diff changeset
54 -- values are implementation defined, several of the subtests cannot
kono
parents:
diff changeset
55 -- directly check the accuracy of the results produced. Instead, they
kono
parents:
diff changeset
56 -- verify that the result is within a range of possible values, or
kono
parents:
diff changeset
57 -- that the result of one function can be converted back to the original
kono
parents:
diff changeset
58 -- actual parameter using a "mirror image" conversion function.
kono
parents:
diff changeset
59 --
kono
parents:
diff changeset
60 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
61 -- This test is applicable to all implementations that provide
kono
parents:
diff changeset
62 -- package Interfaces.COBOL. If an implementation provides
kono
parents:
diff changeset
63 -- package Interfaces.COBOL, this test must compile, execute, and
kono
parents:
diff changeset
64 -- report "PASSED".
kono
parents:
diff changeset
65 --
kono
parents:
diff changeset
66 --
kono
parents:
diff changeset
67 -- CHANGE HISTORY:
kono
parents:
diff changeset
68 -- 12 Feb 96 SAIC Initial release for 2.1.
kono
parents:
diff changeset
69 -- 30 May 96 SAIC Incorporated reviewer comments for ACVC 2.1.
kono
parents:
diff changeset
70 -- 27 Oct 96 SAIC Incorporated reviewer comments.
kono
parents:
diff changeset
71 --
kono
parents:
diff changeset
72 --!
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 with Report;
kono
parents:
diff changeset
75 with Ada.Exceptions;
kono
parents:
diff changeset
76 with Interfaces.COBOL; -- N/A => ERROR
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 procedure CXB4006 is
kono
parents:
diff changeset
79 begin
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 Report.Test ("CXB4006", "Check that the functions Valid, Length, " &
kono
parents:
diff changeset
82 "To_Decimal, and To_Packed specific to " &
kono
parents:
diff changeset
83 "Packed_Decimal parameters produce correct " &
kono
parents:
diff changeset
84 "results");
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 Test_Block:
kono
parents:
diff changeset
87 declare
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 use Interfaces.COBOL;
kono
parents:
diff changeset
90 use Ada.Exceptions;
kono
parents:
diff changeset
91 use type Interfaces.COBOL.Numeric;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 type Decimal_Type_1 is delta 0.1 digits 6;
kono
parents:
diff changeset
94 type Decimal_Type_2 is delta 0.01 digits 8;
kono
parents:
diff changeset
95 type Decimal_Type_3 is delta 0.001 digits 10;
kono
parents:
diff changeset
96 type Decimal_Type_4 is delta 0.0001 digits 12;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 package Pack_1 is new Decimal_Conversions(Decimal_Type_1);
kono
parents:
diff changeset
99 package Pack_2 is new Decimal_Conversions(Decimal_Type_2);
kono
parents:
diff changeset
100 package Pack_3 is new Decimal_Conversions(Decimal_Type_3);
kono
parents:
diff changeset
101 package Pack_4 is new Decimal_Conversions(Decimal_Type_4);
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 TC_Dec_1 : Decimal_Type_1 := 12345.6;
kono
parents:
diff changeset
104 TC_Dec_2 : Decimal_Type_2 := 123456.78;
kono
parents:
diff changeset
105 TC_Dec_3 : Decimal_Type_3 := 1234567.890;
kono
parents:
diff changeset
106 TC_Dec_4 : Decimal_Type_4 := 12345678.9012;
kono
parents:
diff changeset
107 TC_Min_Length : Natural := 1;
kono
parents:
diff changeset
108 TC_Max_Length : Natural := 16;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 begin
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- Check that the function Valid with Packed_Decimal and Packed_Format
kono
parents:
diff changeset
113 -- parameters returns True if Item (the Packed_Decimal parameter) has
kono
parents:
diff changeset
114 -- a value consistent with the Packed_Format parameter.
kono
parents:
diff changeset
115 -- Note: Since the formation rules for Packed_Decimal values are
kono
parents:
diff changeset
116 -- implementation defined, the parameter values here are
kono
parents:
diff changeset
117 -- created by function To_Packed.
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 TC_Dec_1 := 1434.3;
kono
parents:
diff changeset
120 if not Pack_1.Valid(Item => Pack_1.To_Packed(TC_Dec_1,
kono
parents:
diff changeset
121 Packed_Unsigned),
kono
parents:
diff changeset
122 Format => Packed_Unsigned)
kono
parents:
diff changeset
123 then
kono
parents:
diff changeset
124 Report.Failed("Incorrect result from function Valid - 1");
kono
parents:
diff changeset
125 end if;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 TC_Dec_2 := -4321.03;
kono
parents:
diff changeset
128 if not Pack_2.Valid(Pack_2.To_Packed(TC_Dec_2, Packed_Signed),
kono
parents:
diff changeset
129 Format => Packed_Signed) or
kono
parents:
diff changeset
130 Pack_2.Valid(Pack_2.To_Packed(TC_Dec_2, Packed_Signed),
kono
parents:
diff changeset
131 Format => Packed_Unsigned)
kono
parents:
diff changeset
132 then
kono
parents:
diff changeset
133 Report.Failed("Incorrect result from function Valid - 2");
kono
parents:
diff changeset
134 end if;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 TC_Dec_3 := 1234567.890;
kono
parents:
diff changeset
137 if not Pack_3.Valid(Pack_3.To_Packed(TC_Dec_3, Packed_Unsigned),
kono
parents:
diff changeset
138 Packed_Unsigned)
kono
parents:
diff changeset
139 then
kono
parents:
diff changeset
140 Report.Failed("Incorrect result from function Valid - 3");
kono
parents:
diff changeset
141 end if;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 TC_Dec_4 := -234.6789;
kono
parents:
diff changeset
144 if not Pack_4.Valid(Item => Pack_4.To_Packed(TC_Dec_4,
kono
parents:
diff changeset
145 Packed_Signed),
kono
parents:
diff changeset
146 Format => Packed_Signed) or
kono
parents:
diff changeset
147 Pack_4.Valid(Item => Pack_4.To_Packed(TC_Dec_4, Packed_Signed),
kono
parents:
diff changeset
148 Format => Packed_Unsigned)
kono
parents:
diff changeset
149 then
kono
parents:
diff changeset
150 Report.Failed("Incorrect result from function Valid - 4");
kono
parents:
diff changeset
151 end if;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- Check that the function Length with Packed_Format parameter returns
kono
parents:
diff changeset
156 -- the minimal length of a Packed_Decimal value sufficient to hold any
kono
parents:
diff changeset
157 -- value of type Num when represented according to parameter Format.
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 if NOT (Pack_1.Length(Packed_Signed) >= TC_Min_Length AND
kono
parents:
diff changeset
160 Pack_1.Length(Packed_Signed) <= TC_Max_Length AND
kono
parents:
diff changeset
161 Pack_1.Length(Packed_Unsigned) >= TC_Min_Length AND
kono
parents:
diff changeset
162 Pack_1.Length(Packed_Unsigned) <= TC_Max_Length)
kono
parents:
diff changeset
163 then
kono
parents:
diff changeset
164 Report.Failed("Incorrect result from function Length - 1");
kono
parents:
diff changeset
165 end if;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 if NOT (Pack_2.Length(Packed_Signed) >= TC_Min_Length AND
kono
parents:
diff changeset
168 Pack_2.Length(Packed_Signed) <= TC_Max_Length AND
kono
parents:
diff changeset
169 Pack_2.Length(Packed_Unsigned) >= TC_Min_Length AND
kono
parents:
diff changeset
170 Pack_2.Length(Packed_Unsigned) <= TC_Max_Length)
kono
parents:
diff changeset
171 then
kono
parents:
diff changeset
172 Report.Failed("Incorrect result from function Length - 2");
kono
parents:
diff changeset
173 end if;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 if NOT (Pack_3.Length(Packed_Signed) >= TC_Min_Length AND
kono
parents:
diff changeset
176 Pack_3.Length(Packed_Signed) <= TC_Max_Length AND
kono
parents:
diff changeset
177 Pack_3.Length(Packed_Unsigned) >= TC_Min_Length AND
kono
parents:
diff changeset
178 Pack_3.Length(Packed_Unsigned) <= TC_Max_Length)
kono
parents:
diff changeset
179 then
kono
parents:
diff changeset
180 Report.Failed("Incorrect result from function Length - 3");
kono
parents:
diff changeset
181 end if;
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 if NOT (Pack_4.Length(Packed_Signed) >= TC_Min_Length AND
kono
parents:
diff changeset
184 Pack_4.Length(Packed_Signed) <= TC_Max_Length AND
kono
parents:
diff changeset
185 Pack_4.Length(Packed_Unsigned) >= TC_Min_Length AND
kono
parents:
diff changeset
186 Pack_4.Length(Packed_Unsigned) <= TC_Max_Length)
kono
parents:
diff changeset
187 then
kono
parents:
diff changeset
188 Report.Failed("Incorrect result from function Length - 4");
kono
parents:
diff changeset
189 end if;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 -- Check that the function To_Decimal with Packed_Decimal and
kono
parents:
diff changeset
194 -- Packed_Format parameters produces a decimal type value corresponding
kono
parents:
diff changeset
195 -- to the Packed_Decimal parameter value Item, under the conditions of
kono
parents:
diff changeset
196 -- the Packed_Format parameter Format.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 begin
kono
parents:
diff changeset
199 TC_Dec_1 := 1234.5;
kono
parents:
diff changeset
200 if Pack_1.To_Decimal(Item => Pack_1.To_Packed(TC_Dec_1,
kono
parents:
diff changeset
201 Packed_Unsigned),
kono
parents:
diff changeset
202 Format => Packed_Unsigned) /= TC_Dec_1
kono
parents:
diff changeset
203 then
kono
parents:
diff changeset
204 Report.Failed("Incorrect result from function To_Decimal - 1");
kono
parents:
diff changeset
205 end if;
kono
parents:
diff changeset
206 exception
kono
parents:
diff changeset
207 when The_Error : others =>
kono
parents:
diff changeset
208 Report.Failed("The following exception was raised in " &
kono
parents:
diff changeset
209 "subtest 1 of function To_Decimal: " &
kono
parents:
diff changeset
210 Exception_Name(The_Error));
kono
parents:
diff changeset
211 end;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 begin
kono
parents:
diff changeset
214 TC_Dec_2 := -123456.50;
kono
parents:
diff changeset
215 if Pack_2.To_Decimal(Pack_2.To_Packed(TC_Dec_2, Packed_Signed),
kono
parents:
diff changeset
216 Format => Packed_Signed) /= TC_Dec_2
kono
parents:
diff changeset
217 then
kono
parents:
diff changeset
218 Report.Failed("Incorrect result from function To_Decimal - 2");
kono
parents:
diff changeset
219 end if;
kono
parents:
diff changeset
220 exception
kono
parents:
diff changeset
221 when The_Error : others =>
kono
parents:
diff changeset
222 Report.Failed("The following exception was raised in " &
kono
parents:
diff changeset
223 "subtest 2 of function To_Decimal: " &
kono
parents:
diff changeset
224 Exception_Name(The_Error));
kono
parents:
diff changeset
225 end;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 begin
kono
parents:
diff changeset
228 TC_Dec_3 := 1234567.809;
kono
parents:
diff changeset
229 if Pack_3.To_Decimal(Pack_3.To_Packed(TC_Dec_3, Packed_Unsigned),
kono
parents:
diff changeset
230 Packed_Unsigned) /= TC_Dec_3
kono
parents:
diff changeset
231 then
kono
parents:
diff changeset
232 Report.Failed("Incorrect result from function To_Decimal - 3");
kono
parents:
diff changeset
233 end if;
kono
parents:
diff changeset
234 exception
kono
parents:
diff changeset
235 when The_Error : others =>
kono
parents:
diff changeset
236 Report.Failed("The following exception was raised in " &
kono
parents:
diff changeset
237 "subtest 3 of function To_Decimal: " &
kono
parents:
diff changeset
238 Exception_Name(The_Error));
kono
parents:
diff changeset
239 end;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 begin
kono
parents:
diff changeset
242 TC_Dec_4 := -789.1234;
kono
parents:
diff changeset
243 if Pack_4.To_Decimal(Item => Pack_4.To_Packed(TC_Dec_4,
kono
parents:
diff changeset
244 Packed_Signed),
kono
parents:
diff changeset
245 Format => Packed_Signed) /= TC_Dec_4
kono
parents:
diff changeset
246 then
kono
parents:
diff changeset
247 Report.Failed("Incorrect result from function To_Decimal - 4");
kono
parents:
diff changeset
248 end if;
kono
parents:
diff changeset
249 exception
kono
parents:
diff changeset
250 when The_Error : others =>
kono
parents:
diff changeset
251 Report.Failed("The following exception was raised in " &
kono
parents:
diff changeset
252 "subtest 4 of function To_Decimal: " &
kono
parents:
diff changeset
253 Exception_Name(The_Error));
kono
parents:
diff changeset
254 end;
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 -- Check that the function To_Packed with Decimal (Num) and
kono
parents:
diff changeset
259 -- Packed_Format parameters produces a Packed_Decimal result that
kono
parents:
diff changeset
260 -- corresponds to the decimal parameter under conditions of the
kono
parents:
diff changeset
261 -- Packed_Format parameter.
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 if Pack_1.To_Packed(Item => 123.4, Format => Packed_Unsigned) =
kono
parents:
diff changeset
264 Pack_1.To_Packed(Item => -123.4, Format => Packed_Signed)
kono
parents:
diff changeset
265 then
kono
parents:
diff changeset
266 Report.Failed("Incorrect result from function To_Packed - 1");
kono
parents:
diff changeset
267 end if;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 if Pack_2.To_Packed( 123.45, Format => Packed_Unsigned) =
kono
parents:
diff changeset
270 Pack_2.To_Packed(-123.45, Format => Packed_Signed)
kono
parents:
diff changeset
271 then
kono
parents:
diff changeset
272 Report.Failed("Incorrect result from function To_Packed - 2");
kono
parents:
diff changeset
273 end if;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 if Pack_3.To_Packed(Item => 123.456, Format => Packed_Unsigned) =
kono
parents:
diff changeset
276 Pack_3.To_Packed(Item => -123.456, Format => Packed_Signed)
kono
parents:
diff changeset
277 then
kono
parents:
diff changeset
278 Report.Failed("Incorrect result from function To_Packed - 3");
kono
parents:
diff changeset
279 end if;
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 if (Pack_4.To_Packed( 123.4567, Packed_Unsigned) =
kono
parents:
diff changeset
282 Pack_4.To_Packed(-123.4567, Packed_Signed)) or
kono
parents:
diff changeset
283 (Pack_4.To_Packed(12345678.9012, Packed_Unsigned) =
kono
parents:
diff changeset
284 Pack_4.To_Packed(12345678.9013, Packed_Unsigned)) or
kono
parents:
diff changeset
285 (Pack_4.To_Packed(12345678.9012, Packed_Unsigned) =
kono
parents:
diff changeset
286 Pack_4.To_Packed(22345678.9012, Packed_Unsigned))
kono
parents:
diff changeset
287 then
kono
parents:
diff changeset
288 Report.Failed("Incorrect result from function To_Packed - 4");
kono
parents:
diff changeset
289 end if;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 -- Check that Conversion_Error is propagated by function To_Packed if
kono
parents:
diff changeset
293 -- the value of the decimal parameter Item is negative and the
kono
parents:
diff changeset
294 -- specified Packed_Format parameter is Packed_Unsigned.
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 begin
kono
parents:
diff changeset
297 if Pack_1.To_Packed(Item => -12.3, Format => Packed_Unsigned) =
kono
parents:
diff changeset
298 Pack_1.To_Packed(Item => 12.3, Format => Packed_Signed)
kono
parents:
diff changeset
299 then
kono
parents:
diff changeset
300 Report.Comment("Should never be printed");
kono
parents:
diff changeset
301 end if;
kono
parents:
diff changeset
302 Report.Failed("Conversion_Error not raised following call to " &
kono
parents:
diff changeset
303 "function To_Packed with a negative parameter " &
kono
parents:
diff changeset
304 "Item and Packed_Format parameter Packed_Unsigned");
kono
parents:
diff changeset
305 exception
kono
parents:
diff changeset
306 when Conversion_Error => null; -- OK, expected exception.
kono
parents:
diff changeset
307 when The_Error : others =>
kono
parents:
diff changeset
308 Report.Failed(Exception_Name(The_Error) & " was incorrectly " &
kono
parents:
diff changeset
309 "raised following call to function To_Packed " &
kono
parents:
diff changeset
310 "with a negative parameter Item and " &
kono
parents:
diff changeset
311 "Packed_Format parameter Packed_Unsigned");
kono
parents:
diff changeset
312 end;
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 exception
kono
parents:
diff changeset
315 when The_Error : others =>
kono
parents:
diff changeset
316 Report.Failed("The following exception was raised in the " &
kono
parents:
diff changeset
317 "Test_Block: " & Exception_Name(The_Error));
kono
parents:
diff changeset
318 end Test_Block;
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 Report.Result;
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 end CXB4006;