annotate gcc/testsuite/ada/acats/tests/c3/c392a01.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 -- C392A01.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 use of a class-wide formal parameter allows for the
kono
parents:
diff changeset
28 -- proper dispatching of objects to the appropriate implementation of
kono
parents:
diff changeset
29 -- a primitive operation. Check this for the root tagged type defined
kono
parents:
diff changeset
30 -- in a package, and the extended type is defined in that same package.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- TEST DESCRIPTION:
kono
parents:
diff changeset
33 -- Declare a root tagged type, and some associated primitive operations.
kono
parents:
diff changeset
34 -- Extend the root type, and override one or more primitive operations,
kono
parents:
diff changeset
35 -- inheriting the other primitive operations from the root type.
kono
parents:
diff changeset
36 -- Derive from the extended type, again overriding some primitive
kono
parents:
diff changeset
37 -- operations and inheriting others (including some that the parent
kono
parents:
diff changeset
38 -- inherited).
kono
parents:
diff changeset
39 -- Define a subprogram with a class-wide parameter, inside of which is a
kono
parents:
diff changeset
40 -- call on a dispatching primitive operation. These primitive operations
kono
parents:
diff changeset
41 -- modify global variables (the class-wide parameter has mode IN).
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- The following hierarchy of tagged types and primitive operations is
kono
parents:
diff changeset
46 -- utilized in this test:
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 -- type Bank_Account (root)
kono
parents:
diff changeset
49 -- |
kono
parents:
diff changeset
50 -- | Operations
kono
parents:
diff changeset
51 -- | Increment_Bank_Reserve
kono
parents:
diff changeset
52 -- | Assign_Representative
kono
parents:
diff changeset
53 -- | Increment_Counters
kono
parents:
diff changeset
54 -- | Open
kono
parents:
diff changeset
55 -- |
kono
parents:
diff changeset
56 -- type Savings_Account (extended from Bank_Account)
kono
parents:
diff changeset
57 -- |
kono
parents:
diff changeset
58 -- | Operations
kono
parents:
diff changeset
59 -- | (Increment_Bank_Reserve) (inherited)
kono
parents:
diff changeset
60 -- | Assign_Representative (overridden)
kono
parents:
diff changeset
61 -- | Increment_Counters (overridden)
kono
parents:
diff changeset
62 -- | Open (overridden)
kono
parents:
diff changeset
63 -- |
kono
parents:
diff changeset
64 -- type Preferred_Account (extended from Savings_Account)
kono
parents:
diff changeset
65 -- |
kono
parents:
diff changeset
66 -- | Operations
kono
parents:
diff changeset
67 -- | (Increment_Bank_Reserve) (inherited twice - Bank_Acct.)
kono
parents:
diff changeset
68 -- | (Assign_Representative) (inherited - Savings_Acct.)
kono
parents:
diff changeset
69 -- | Increment_Counters (overridden)
kono
parents:
diff changeset
70 -- | Open (overridden)
kono
parents:
diff changeset
71 --
kono
parents:
diff changeset
72 --
kono
parents:
diff changeset
73 -- In this test, we are concerned with the following selection of dispatching
kono
parents:
diff changeset
74 -- calls, accomplished with the use of a Bank_Account'Class IN procedure
kono
parents:
diff changeset
75 -- parameter :
kono
parents:
diff changeset
76 --
kono
parents:
diff changeset
77 -- \ Type
kono
parents:
diff changeset
78 -- Prim. Op \ Bank_Account Savings_Account Preferred_Account
kono
parents:
diff changeset
79 -- \------------------------------------------------
kono
parents:
diff changeset
80 -- Increment_Bank_Reserve| X X X
kono
parents:
diff changeset
81 -- Assign_Representative | X
kono
parents:
diff changeset
82 -- Increment_Counters | X X X
kono
parents:
diff changeset
83 --
kono
parents:
diff changeset
84 --
kono
parents:
diff changeset
85 --
kono
parents:
diff changeset
86 -- The location of the declaration and derivation of the root and extended
kono
parents:
diff changeset
87 -- types will be varied over a series of tests. Locations of declaration
kono
parents:
diff changeset
88 -- and derivation for a particular test are marked with an asterisk (*).
kono
parents:
diff changeset
89 --
kono
parents:
diff changeset
90 -- Root type:
kono
parents:
diff changeset
91 --
kono
parents:
diff changeset
92 -- * Declared in package.
kono
parents:
diff changeset
93 -- Declared in generic package.
kono
parents:
diff changeset
94 --
kono
parents:
diff changeset
95 -- Extended types:
kono
parents:
diff changeset
96 --
kono
parents:
diff changeset
97 -- * Derived in parent location.
kono
parents:
diff changeset
98 -- Derived in a nested package.
kono
parents:
diff changeset
99 -- Derived in a nested subprogram.
kono
parents:
diff changeset
100 -- Derived in a nested generic package.
kono
parents:
diff changeset
101 -- Derived in a separate package.
kono
parents:
diff changeset
102 -- Derived in a separate visible child package.
kono
parents:
diff changeset
103 -- Derived in a separate private child package.
kono
parents:
diff changeset
104 --
kono
parents:
diff changeset
105 -- Primitive Operations:
kono
parents:
diff changeset
106 --
kono
parents:
diff changeset
107 -- * Procedures with same parameter profile.
kono
parents:
diff changeset
108 -- Procedures with different parameter profile.
kono
parents:
diff changeset
109 -- Functions with same parameter profile.
kono
parents:
diff changeset
110 -- Functions with different parameter profile.
kono
parents:
diff changeset
111 -- Mixture of Procedures and Functions.
kono
parents:
diff changeset
112 --
kono
parents:
diff changeset
113 --
kono
parents:
diff changeset
114 -- TEST FILES:
kono
parents:
diff changeset
115 -- This test depends on the following foundation code:
kono
parents:
diff changeset
116 --
kono
parents:
diff changeset
117 -- F392A00.A
kono
parents:
diff changeset
118 --
kono
parents:
diff changeset
119 -- The following files comprise this test:
kono
parents:
diff changeset
120 --
kono
parents:
diff changeset
121 -- => C392A01.A
kono
parents:
diff changeset
122 --
kono
parents:
diff changeset
123 --
kono
parents:
diff changeset
124 -- CHANGE HISTORY:
kono
parents:
diff changeset
125 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
126 --
kono
parents:
diff changeset
127 --!
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 with F392A00; -- package Accounts
kono
parents:
diff changeset
130 with Report;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure C392A01 is
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 package Accounts renames F392A00;
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 -- Declare account objects.
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 B_Account : Accounts.Bank_Account;
kono
parents:
diff changeset
139 S_Account : Accounts.Savings_Account;
kono
parents:
diff changeset
140 P_Account : Accounts.Preferred_Account;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 -- Procedures to operate on accounts.
kono
parents:
diff changeset
143 -- Each uses a class-wide IN parameter, as well as a call to a
kono
parents:
diff changeset
144 -- dispatching operation.
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 -- Procedure Tabulate_Account performs a dispatching call on a primitive
kono
parents:
diff changeset
147 -- operation that has been overridden for each of the extended types.
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 procedure Tabulate_Account (Acct : in Accounts.Bank_Account'Class) is
kono
parents:
diff changeset
150 begin
kono
parents:
diff changeset
151 Accounts.Increment_Counters (Acct); -- Dispatch according to tag.
kono
parents:
diff changeset
152 end Tabulate_Account;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- Procedure Accumulate_Reserve performs a dispatching call on a
kono
parents:
diff changeset
156 -- primitive operation that has been defined for the root type and
kono
parents:
diff changeset
157 -- inherited by each derived type.
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 procedure Accumulate_Reserve (Acct : in Accounts.Bank_Account'Class) is
kono
parents:
diff changeset
160 begin
kono
parents:
diff changeset
161 Accounts.Increment_Bank_Reserve (Acct); -- Dispatch according to tag.
kono
parents:
diff changeset
162 end Accumulate_Reserve;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 -- Procedure Resolve_Dispute performs a dispatching call on a primitive
kono
parents:
diff changeset
166 -- operation that has been defined in the root type, overridden in the
kono
parents:
diff changeset
167 -- first derived extended type, and inherited by the subsequent extended
kono
parents:
diff changeset
168 -- type.
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 procedure Resolve_Dispute (Acct : in Accounts.Bank_Account'Class) is
kono
parents:
diff changeset
171 begin
kono
parents:
diff changeset
172 Accounts.Assign_Representative (Acct); -- Dispatch according to tag.
kono
parents:
diff changeset
173 end Resolve_Dispute;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 begin -- Main test procedure.
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 Report.Test ("C392A01", "Check that the use of a class-wide parameter " &
kono
parents:
diff changeset
180 "allows for proper dispatching where root type " &
kono
parents:
diff changeset
181 "and extended types are declared in the same " &
kono
parents:
diff changeset
182 "package" );
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 Bank_Account_Subtest:
kono
parents:
diff changeset
185 declare
kono
parents:
diff changeset
186 use Accounts;
kono
parents:
diff changeset
187 begin
kono
parents:
diff changeset
188 Accounts.Open (B_Account);
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 -- Demonstrate class-wide parameter allowing dispatch by a primitive
kono
parents:
diff changeset
191 -- operation that has been defined for this specific type.
kono
parents:
diff changeset
192 Accumulate_Reserve (Acct => B_Account);
kono
parents:
diff changeset
193 Tabulate_Account (B_Account);
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 if (Accounts.Bank_Reserve /= Accounts.Opening_Balance) or
kono
parents:
diff changeset
196 (Accounts.Number_Of_Accounts (Bank) /= 1) or
kono
parents:
diff changeset
197 (Accounts.Number_Of_Accounts (Total) /= 1)
kono
parents:
diff changeset
198 then
kono
parents:
diff changeset
199 Report.Failed ("Failed in Bank_Account_Subtest");
kono
parents:
diff changeset
200 end if;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 end Bank_Account_Subtest;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 Savings_Account_Subtest:
kono
parents:
diff changeset
206 declare
kono
parents:
diff changeset
207 use Accounts;
kono
parents:
diff changeset
208 begin
kono
parents:
diff changeset
209 Accounts.Open (Acct => S_Account);
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 -- Demonstrate class-wide parameter allowing dispatch by a primitive
kono
parents:
diff changeset
212 -- operation that has been inherited by this extended type.
kono
parents:
diff changeset
213 Accumulate_Reserve (Acct => S_Account);
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 -- Demonstrate class-wide parameter allowing dispatch by a primitive
kono
parents:
diff changeset
216 -- operation that has been overridden for this extended type.
kono
parents:
diff changeset
217 Resolve_Dispute (Acct => S_Account);
kono
parents:
diff changeset
218 Tabulate_Account (S_Account);
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 if Accounts.Bank_Reserve /= (3.0 * Accounts.Opening_Balance) or
kono
parents:
diff changeset
221 Accounts.Daily_Representative /= Accounts.Manager or
kono
parents:
diff changeset
222 Accounts.Number_Of_Accounts (Savings) /= 1 or
kono
parents:
diff changeset
223 Accounts.Number_Of_Accounts (Total) /= 2
kono
parents:
diff changeset
224 then
kono
parents:
diff changeset
225 Report.Failed ("Failed in Savings_Account_Subtest");
kono
parents:
diff changeset
226 end if;
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 end Savings_Account_Subtest;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 Preferred_Account_Subtest:
kono
parents:
diff changeset
232 declare
kono
parents:
diff changeset
233 use Accounts;
kono
parents:
diff changeset
234 begin
kono
parents:
diff changeset
235 Accounts.Open (P_Account);
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 -- Verify that the correct implementation of Open (overridden) was
kono
parents:
diff changeset
238 -- used for the Preferred_Account object.
kono
parents:
diff changeset
239 if not Accounts.Verify_Open (P_Account) then
kono
parents:
diff changeset
240 Report.Failed ("Incorrect values for init. Preferred Acct object");
kono
parents:
diff changeset
241 end if;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 -- Demonstrate class-wide parameter allowing dispatch by a primitive
kono
parents:
diff changeset
244 -- operation that has been twice inherited by this extended type.
kono
parents:
diff changeset
245 Accumulate_Reserve (Acct => P_Account);
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 -- Demonstrate class-wide parameter allowing dispatch by a primitive
kono
parents:
diff changeset
248 -- operation that has been overridden for this extended type (the
kono
parents:
diff changeset
249 -- operation was overridden by its parent type as well).
kono
parents:
diff changeset
250 Tabulate_Account (P_Account);
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 if Accounts.Bank_Reserve /= 1300.00 or
kono
parents:
diff changeset
253 Accounts.Number_Of_Accounts (Preferred) /= 1 or
kono
parents:
diff changeset
254 Accounts.Number_Of_Accounts (Total) /= 3
kono
parents:
diff changeset
255 then
kono
parents:
diff changeset
256 Report.Failed ("Failed in Preferred_Account_Subtest");
kono
parents:
diff changeset
257 end if;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 end Preferred_Account_Subtest;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 Report.Result;
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 end C392A01;
kono
parents:
diff changeset
265