annotate gcc/testsuite/ada/acats/tests/cxg/cxg1001.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 -- CXG1001.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 subprograms defined in the package
kono
parents:
diff changeset
28 -- Ada.Numerics.Generic_Complex_Types provide correct results.
kono
parents:
diff changeset
29 -- Specifically, check the functions Re, Im (both versions), procedures
kono
parents:
diff changeset
30 -- Set_Re, Set_Im (both versions), functions Compose_From_Cartesian (all
kono
parents:
diff changeset
31 -- versions), Compose_From_Polar, Modulus, Argument, and "abs".
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION:
kono
parents:
diff changeset
34 -- The generic package Generic_Complex_Types
kono
parents:
diff changeset
35 -- is instantiated with a real type (new Float), and the results
kono
parents:
diff changeset
36 -- produced by the specified subprograms are verified.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
39 -- This test applies only to implementations supporting the
kono
parents:
diff changeset
40 -- Numerics Annex.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- CHANGE HISTORY:
kono
parents:
diff changeset
44 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
45 -- 15 Nov 95 SAIC Corrected visibility problems for ACVC 2.0.1.
kono
parents:
diff changeset
46 -- Modified subtest for Compose_From_Polar.
kono
parents:
diff changeset
47 -- 29 Sep 96 SAIC Incorporated reviewer comments.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 --!
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 with Ada.Numerics.Generic_Complex_Types;
kono
parents:
diff changeset
52 with Report;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure CXG1001 is
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 begin
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 Report.Test ("CXG1001", "Check that the subprograms defined in " &
kono
parents:
diff changeset
59 "the package Ada.Numerics.Generic_Complex_Types " &
kono
parents:
diff changeset
60 "provide correct results");
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 Test_Block:
kono
parents:
diff changeset
63 declare
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 type Real_Type is new Float;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 package Complex_Pack is new
kono
parents:
diff changeset
68 Ada.Numerics.Generic_Complex_Types(Real_Type);
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 use type Complex_Pack.Complex;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 -- Declare a zero valued complex number.
kono
parents:
diff changeset
73 Complex_Zero : constant Complex_Pack.Complex := (0.0, 0.0);
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 TC_Complex : Complex_Pack.Complex := Complex_Zero;
kono
parents:
diff changeset
76 TC_Imaginary : Complex_Pack.Imaginary;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 begin
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 -- Check that the procedures Set_Re and Set_Im (both versions) provide
kono
parents:
diff changeset
81 -- correct results.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 declare
kono
parents:
diff changeset
84 TC_Complex_Real_Field : Complex_Pack.Complex := (5.0, 0.0);
kono
parents:
diff changeset
85 TC_Complex_Both_Fields : Complex_Pack.Complex := (5.0, 7.0);
kono
parents:
diff changeset
86 begin
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Complex_Pack.Set_Re(X => TC_Complex, Re => 5.0);
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 if TC_Complex /= TC_Complex_Real_Field then
kono
parents:
diff changeset
91 Report.Failed("Incorrect results from Procedure Set_Re");
kono
parents:
diff changeset
92 end if;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Complex_Pack.Set_Im(X => TC_Complex, Im => 7.0);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 if TC_Complex.Re /= 5.0 or
kono
parents:
diff changeset
97 TC_Complex.Im /= 7.0 or
kono
parents:
diff changeset
98 TC_Complex /= TC_Complex_Both_Fields
kono
parents:
diff changeset
99 then
kono
parents:
diff changeset
100 Report.Failed("Incorrect results from Procedure Set_Im " &
kono
parents:
diff changeset
101 "with Complex argument");
kono
parents:
diff changeset
102 end if;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 Complex_Pack.Set_Im(X => TC_Imaginary, Im => 3.0);
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 if Complex_Pack.Im(TC_Imaginary) /= 3.0 then
kono
parents:
diff changeset
108 Report.Failed("Incorrect results returned following the use " &
kono
parents:
diff changeset
109 "of Procedure Set_Im with Imaginary argument");
kono
parents:
diff changeset
110 end if;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 end;
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 -- Check that the functions Re and Im (both versions) provide
kono
parents:
diff changeset
116 -- correct results.
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 declare
kono
parents:
diff changeset
119 TC_Complex_1 : Complex_Pack.Complex := (1.0, 0.0);
kono
parents:
diff changeset
120 TC_Complex_2 : Complex_Pack.Complex := (0.0, 2.0);
kono
parents:
diff changeset
121 TC_Complex_3 : Complex_Pack.Complex := (4.0, 3.0);
kono
parents:
diff changeset
122 begin
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 -- Function Re.
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 if Complex_Pack.Re(X => TC_Complex_1) /= 1.0 or
kono
parents:
diff changeset
127 Complex_Pack.Re(X => TC_Complex_2) /= 0.0 or
kono
parents:
diff changeset
128 Complex_Pack.Re(X => TC_Complex_3) /= 4.0
kono
parents:
diff changeset
129 then
kono
parents:
diff changeset
130 Report.Failed("Incorrect results from Function Re");
kono
parents:
diff changeset
131 end if;
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 -- Function Im; version with Complex argument.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 if Complex_Pack.Im(X => TC_Complex_1) /= 0.0 or
kono
parents:
diff changeset
136 Complex_Pack.Im(X => TC_Complex_2) /= 2.0 or
kono
parents:
diff changeset
137 Complex_Pack.Im(X => TC_Complex_3) /= 3.0
kono
parents:
diff changeset
138 then
kono
parents:
diff changeset
139 Report.Failed("Incorrect results from Function Im " &
kono
parents:
diff changeset
140 "with Complex argument");
kono
parents:
diff changeset
141 end if;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 -- Function Im; version with Imaginary argument.
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 if Complex_Pack.Im(Complex_Pack.i) /= 1.0 or
kono
parents:
diff changeset
147 Complex_Pack.Im(Complex_Pack.j) /= 1.0
kono
parents:
diff changeset
148 then
kono
parents:
diff changeset
149 Report.Failed("Incorrect results from use of Function Im " &
kono
parents:
diff changeset
150 "when used with an Imaginary argument");
kono
parents:
diff changeset
151 end if;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 end;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 -- Verify the results of the three versions of Function
kono
parents:
diff changeset
157 -- Compose_From_Cartesian
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 declare
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 Zero : constant Real_Type := 0.0;
kono
parents:
diff changeset
162 Six : constant Real_Type := 6.0;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 TC_Complex_1 : Complex_Pack.Complex := (3.0, 8.0);
kono
parents:
diff changeset
165 TC_Complex_2 : Complex_Pack.Complex := (Six, Zero);
kono
parents:
diff changeset
166 TC_Complex_3 : Complex_Pack.Complex := (Zero, 1.0);
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 begin
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 TC_Complex := Complex_Pack.Compose_From_Cartesian(3.0, 8.0);
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 if TC_Complex /= TC_Complex_1 then
kono
parents:
diff changeset
173 Report.Failed("Incorrect results from Function " &
kono
parents:
diff changeset
174 "Compose_From_Cartesian - 1");
kono
parents:
diff changeset
175 end if;
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 -- If only one component is given, the other component is
kono
parents:
diff changeset
178 -- implicitly zero (Both components are set by the following two
kono
parents:
diff changeset
179 -- function calls).
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 TC_Complex := Complex_Pack.Compose_From_Cartesian(Re => 6.0);
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 if TC_Complex /= TC_Complex_2 then
kono
parents:
diff changeset
184 Report.Failed("Incorrect results from Function " &
kono
parents:
diff changeset
185 "Compose_From_Cartesian - 2");
kono
parents:
diff changeset
186 end if;
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 TC_Complex :=
kono
parents:
diff changeset
189 Complex_Pack.Compose_From_Cartesian(Im => Complex_Pack.i);
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 if TC_Complex /= TC_Complex_3 then
kono
parents:
diff changeset
192 Report.Failed("Incorrect results from Function " &
kono
parents:
diff changeset
193 "Compose_From_Cartesian - 3");
kono
parents:
diff changeset
194 end if;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 end;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -- Verify the results of Function Compose_From_Polar, Modulus, "abs",
kono
parents:
diff changeset
200 -- and Argument.
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 declare
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 use Complex_Pack;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 TC_Modulus,
kono
parents:
diff changeset
207 TC_Argument : Real_Type := 0.0;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 Angle_0 : constant Real_Type := 0.0;
kono
parents:
diff changeset
211 Angle_90 : constant Real_Type := 90.0;
kono
parents:
diff changeset
212 Angle_180 : constant Real_Type := 180.0;
kono
parents:
diff changeset
213 Angle_270 : constant Real_Type := 270.0;
kono
parents:
diff changeset
214 Angle_360 : constant Real_Type := 360.0;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 begin
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 -- Verify the result of Function Compose_From_Polar.
kono
parents:
diff changeset
219 -- When the value of the parameter Modulus is zero, the
kono
parents:
diff changeset
220 -- Compose_From_Polar function yields a result of zero.
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 if Compose_From_Polar(0.0, 30.0, 360.0) /= Complex_Zero
kono
parents:
diff changeset
223 then
kono
parents:
diff changeset
224 Report.Failed("Incorrect result from Function " &
kono
parents:
diff changeset
225 "Compose_From_Polar - 1");
kono
parents:
diff changeset
226 end if;
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 -- When the value of the parameter Argument is equal to a multiple
kono
parents:
diff changeset
229 -- of the quarter cycle, the result of the Compose_From_Polar
kono
parents:
diff changeset
230 -- function with specified cycle lies on one of the axes.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 if Compose_From_Polar( 5.0, Angle_0, Angle_360) /= (5.0, 0.0) or
kono
parents:
diff changeset
233 Compose_From_Polar( 5.0, Angle_90, Angle_360) /= (0.0, 5.0) or
kono
parents:
diff changeset
234 Compose_From_Polar(-5.0, Angle_180, Angle_360) /= (5.0, 0.0) or
kono
parents:
diff changeset
235 Compose_From_Polar(-5.0, Angle_270, Angle_360) /= (0.0, 5.0) or
kono
parents:
diff changeset
236 Compose_From_Polar(-5.0, Angle_90, Angle_360) /= (0.0, -5.0) or
kono
parents:
diff changeset
237 Compose_From_Polar( 5.0, Angle_270, Angle_360) /= (0.0, -5.0)
kono
parents:
diff changeset
238 then
kono
parents:
diff changeset
239 Report.Failed("Incorrect result from Function " &
kono
parents:
diff changeset
240 "Compose_From_Polar - 2");
kono
parents:
diff changeset
241 end if;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 -- When the parameter to Function Argument represents a point on
kono
parents:
diff changeset
244 -- the non-negative real axis, the function yields a zero result.
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 if Argument(Complex_Zero, Angle_360) /= 0.0 then
kono
parents:
diff changeset
247 Report.Failed("Incorrect result from Function Argument");
kono
parents:
diff changeset
248 end if;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 -- Function Modulus
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 if Modulus(Complex_Zero) /= 0.0 or
kono
parents:
diff changeset
253 Modulus(Compose_From_Polar( 5.0, Angle_90, Angle_360)) /= 5.0 or
kono
parents:
diff changeset
254 Modulus(Compose_From_Polar(-5.0, Angle_180, Angle_360)) /= 5.0
kono
parents:
diff changeset
255 then
kono
parents:
diff changeset
256 Report.Failed("Incorrect results from Function Modulus");
kono
parents:
diff changeset
257 end if;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 -- Function "abs", a rename of Function Modulus.
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 if "abs"(Complex_Zero) /= 0.0 or
kono
parents:
diff changeset
262 "abs"(Compose_From_Polar( 5.0, Angle_90, Angle_360)) /= 5.0 or
kono
parents:
diff changeset
263 "abs"(Compose_From_Polar(-5.0, Angle_180, Angle_360)) /= 5.0
kono
parents:
diff changeset
264 then
kono
parents:
diff changeset
265 Report.Failed("Incorrect results from Function abs");
kono
parents:
diff changeset
266 end if;
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 end;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 exception
kono
parents:
diff changeset
271 when others => Report.Failed ("Exception raised in Test_Block");
kono
parents:
diff changeset
272 end Test_Block;
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 Report.Result;
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 end CXG1001;