annotate gcc/testsuite/ada/acats/tests/cxg/cxg1002.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 -- CXG1002.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 the prescribed results.
kono
parents:
diff changeset
29 -- Specifically, check the various versions of functions "+" and "-".
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- This test checks that the subprograms "+" and "-" defined in the
kono
parents:
diff changeset
33 -- Generic_Complex_Types package provide the results prescribed for the
kono
parents:
diff changeset
34 -- evaluation of these complex arithmetic operations. The functions
kono
parents:
diff changeset
35 -- Re and Im are used to extract the appropriate component of the
kono
parents:
diff changeset
36 -- complex result, in order that the prescribed result component can be
kono
parents:
diff changeset
37 -- verified.
kono
parents:
diff changeset
38 -- The generic package is instantiated with a real type (new Float),
kono
parents:
diff changeset
39 -- and the results produced by the specified subprograms are verified.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- SPECIAL REQUIREMENTS:
kono
parents:
diff changeset
42 -- This test can be run in either "relaxed" or "strict" mode.
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- CHANGE HISTORY:
kono
parents:
diff changeset
46 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 --!
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 with Ada.Numerics.Generic_Complex_Types;
kono
parents:
diff changeset
51 with Report;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 procedure CXG1002 is
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 begin
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 Report.Test ("CXG1002", "Check that the subprograms defined in " &
kono
parents:
diff changeset
58 "the package Ada.Numerics.Generic_Complex_Types " &
kono
parents:
diff changeset
59 "provide the prescribed results");
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 Test_Block:
kono
parents:
diff changeset
62 declare
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 type Real_Type is new Float;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 package Complex_Pack is new
kono
parents:
diff changeset
67 Ada.Numerics.Generic_Complex_Types(Real_Type);
kono
parents:
diff changeset
68 use Complex_Pack;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- Declare a zero valued complex number using the record
kono
parents:
diff changeset
71 -- aggregate approach.
kono
parents:
diff changeset
72
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,
kono
parents:
diff changeset
76 TC_Complex_Right,
kono
parents:
diff changeset
77 TC_Complex_Left : Complex_Pack.Complex := Complex_Zero;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 TC_Real : Real_Type := 0.0;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 TC_Imaginary : Complex_Pack.Imaginary;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 begin
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 -- Check that the imaginary component of the result of a binary addition
kono
parents:
diff changeset
87 -- operator that yields a result of complex type is exact when either
kono
parents:
diff changeset
88 -- of its operands is of pure-real type.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 TC_Complex := Compose_From_Cartesian(2.0, 3.0);
kono
parents:
diff changeset
91 TC_Real := 3.0;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 if Im("+"(Left => TC_Complex, Right => TC_Real)) /= 3.0 or
kono
parents:
diff changeset
94 Im("+"(TC_Complex, 6.0)) /= 3.0 or
kono
parents:
diff changeset
95 Im(TC_Complex + TC_Real) /= 3.0 or
kono
parents:
diff changeset
96 Im(TC_Complex + 5.0) /= 3.0 or
kono
parents:
diff changeset
97 Im((7.0, 2.0) + 1.0) /= 2.0 or
kono
parents:
diff changeset
98 Im((7.0, 5.0) + (-2.0)) /= 5.0 or
kono
parents:
diff changeset
99 Im((-7.0, -2.0) + 1.0) /= -2.0 or
kono
parents:
diff changeset
100 Im((-7.0, -3.0) + (-3.0)) /= -3.0
kono
parents:
diff changeset
101 then
kono
parents:
diff changeset
102 Report.Failed("Incorrect results from Function ""+"" with " &
kono
parents:
diff changeset
103 "one Complex and one Real argument - 1");
kono
parents:
diff changeset
104 end if;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 if Im("+"(Left => TC_Real, Right => TC_Complex)) /= 3.0 or
kono
parents:
diff changeset
107 Im("+"(4.0, TC_Complex)) /= 3.0 or
kono
parents:
diff changeset
108 Im(TC_Real + TC_Complex) /= 3.0 or
kono
parents:
diff changeset
109 Im(9.0 + TC_Complex) /= 3.0 or
kono
parents:
diff changeset
110 Im(1.0 + (7.0, -9.0)) /= -9.0 or
kono
parents:
diff changeset
111 Im((-2.0) + (7.0, 2.0)) /= 2.0 or
kono
parents:
diff changeset
112 Im(1.0 + (-7.0, -5.0)) /= -5.0 or
kono
parents:
diff changeset
113 Im((-3.0) + (-7.0, 16.0)) /= 16.0
kono
parents:
diff changeset
114 then
kono
parents:
diff changeset
115 Report.Failed("Incorrect results from Function ""+"" with " &
kono
parents:
diff changeset
116 "one Complex and one Real argument - 2");
kono
parents:
diff changeset
117 end if;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- Check that the imaginary component of the result of a binary
kono
parents:
diff changeset
121 -- subtraction operator that yields a result of complex type is exact
kono
parents:
diff changeset
122 -- when its right operand is of pure-real type.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 TC_Complex := (8.0, -4.0);
kono
parents:
diff changeset
125 TC_Real := 2.0;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 if Im("-"(Left => TC_Complex, Right => TC_Real)) /= -4.0 or
kono
parents:
diff changeset
128 Im("-"(TC_Complex, 5.0)) /= -4.0 or
kono
parents:
diff changeset
129 Im(TC_Complex - TC_Real) /= -4.0 or
kono
parents:
diff changeset
130 Im(TC_Complex - 4.0) /= -4.0 or
kono
parents:
diff changeset
131 Im((6.0, 5.0) - 1.0) /= 5.0 or
kono
parents:
diff changeset
132 Im((6.0, 13.0) - 7.0) /= 13.0 or
kono
parents:
diff changeset
133 Im((-5.0, 3.0) - (2.0)) /= 3.0 or
kono
parents:
diff changeset
134 Im((-5.0, -6.0) - (-3.0)) /= -6.0
kono
parents:
diff changeset
135 then
kono
parents:
diff changeset
136 Report.Failed("Incorrect results from Function ""-"" with " &
kono
parents:
diff changeset
137 "one Complex and one Real argument");
kono
parents:
diff changeset
138 end if;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 -- Check that the real component of the result of a binary addition
kono
parents:
diff changeset
142 -- operator that yields a result of complex type is exact when either
kono
parents:
diff changeset
143 -- of its operands is of pure-imaginary type.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 TC_Complex := (5.0, 0.0);
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 if Re("+"(Left => TC_Complex, Right => i)) /= 5.0 or
kono
parents:
diff changeset
148 Re("+"(Complex_Pack.j, TC_Complex)) /= 5.0 or
kono
parents:
diff changeset
149 Re((-8.0, 5.0) + ( 2.0*i)) /= -8.0 or
kono
parents:
diff changeset
150 Re((2.0, 5.0) + (-2.0*i)) /= 2.0 or
kono
parents:
diff changeset
151 Re((-20.0, -5.0) + ( 3.0*i)) /= -20.0 or
kono
parents:
diff changeset
152 Re((6.0, -5.0) + (-3.0*i)) /= 6.0
kono
parents:
diff changeset
153 then
kono
parents:
diff changeset
154 Report.Failed("Incorrect results from Function ""+"" with " &
kono
parents:
diff changeset
155 "one Complex and one Imaginary argument");
kono
parents:
diff changeset
156 end if;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 -- Check that the real component of the result of a binary
kono
parents:
diff changeset
160 -- subtraction operator that yields a result of complex type is exact
kono
parents:
diff changeset
161 -- when its right operand is of pure-imaginary type.
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 TC_Complex := TC_Complex + i; -- Should produce (5.0, 1.0)
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 if Re("-"(TC_Complex, i)) /= 5.0 or
kono
parents:
diff changeset
166 Re((-4.0, 4.0) - ( 2.0*i)) /= -4.0 or
kono
parents:
diff changeset
167 Re((9.0, 4.0) - ( 5.0*i)) /= 9.0 or
kono
parents:
diff changeset
168 Re((16.0, -5.0) - ( 3.0*i)) /= 16.0 or
kono
parents:
diff changeset
169 Re((-3.0, -5.0) - (-4.0*i)) /= -3.0
kono
parents:
diff changeset
170 then
kono
parents:
diff changeset
171 Report.Failed("Incorrect results from Function ""-"" with " &
kono
parents:
diff changeset
172 "one Complex and one Imaginary argument");
kono
parents:
diff changeset
173 end if;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 -- Check that the result of a binary addition operation is exact when
kono
parents:
diff changeset
177 -- one of its operands is of real type and the other is of
kono
parents:
diff changeset
178 -- pure-imaginary type; the operator is analogous to the
kono
parents:
diff changeset
179 -- Compose_From_Cartesian function; it performs no arithmetic.
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 TC_Complex := Complex_Pack."+"(5.0, Complex_Pack.i);
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 if TC_Complex /= (5.0, 1.0) or
kono
parents:
diff changeset
184 (4.0 + i) /= (4.0, 1.0) or
kono
parents:
diff changeset
185 "+"(Left => j, Right => 3.0) /= (3.0, 1.0)
kono
parents:
diff changeset
186 then
kono
parents:
diff changeset
187 Report.Failed("Incorrect results from Function ""+"" with " &
kono
parents:
diff changeset
188 "one Real and one Imaginary argument");
kono
parents:
diff changeset
189 end if;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 exception
kono
parents:
diff changeset
193 when others => Report.Failed ("Exception raised in Test_Block");
kono
parents:
diff changeset
194 end Test_Block;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 Report.Result;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 end CXG1002;