annotate gcc/testsuite/ada/acats/tests/c3/c390003.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 -- C390003.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 for a subtype S of a tagged type T, S'Class denotes a
kono
parents:
diff changeset
28 -- class-wide subtype. Check that T'Tag denotes the tag of the type T,
kono
parents:
diff changeset
29 -- and that, for a class-wide tagged type X, X'Tag denotes the tag of X.
kono
parents:
diff changeset
30 -- Check that the tags of stand alone objects, record and array
kono
parents:
diff changeset
31 -- components, aggregates, and formal parameters identify their type.
kono
parents:
diff changeset
32 -- Check that the tag of a value of a formal parameter is that of the
kono
parents:
diff changeset
33 -- actual parameter, even if the actual is passed by a view conversion.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- TEST DESCRIPTION:
kono
parents:
diff changeset
36 -- This test defines a class hierarchy (based on C390002) and
kono
parents:
diff changeset
37 -- uses it to determine the correctness of the resulting tag
kono
parents:
diff changeset
38 -- information generated by the compiler. A type is defined in the
kono
parents:
diff changeset
39 -- class which contains components of the class as part of its
kono
parents:
diff changeset
40 -- definition. This is to reduce the overall number of types
kono
parents:
diff changeset
41 -- required, and to achieve the required nesting to accomplish
kono
parents:
diff changeset
42 -- this test. The model is that of a car carrier truck; both car
kono
parents:
diff changeset
43 -- and truck being in the class of Vehicle.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- Class Hierarchy:
kono
parents:
diff changeset
46 -- Vehicle - - - - - - - (Bicycle)
kono
parents:
diff changeset
47 -- / | \ / \
kono
parents:
diff changeset
48 -- Truck Car Q_Machine Tandem Motorcycle
kono
parents:
diff changeset
49 -- |
kono
parents:
diff changeset
50 -- Auto_Carrier
kono
parents:
diff changeset
51 -- Contains:
kono
parents:
diff changeset
52 -- Auto_Carrier( Car )
kono
parents:
diff changeset
53 -- Q_Machine( Car, Motorcycle )
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 -- CHANGE HISTORY:
kono
parents:
diff changeset
58 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
59 -- 19 Dec 94 SAIC Removed ARM references from objective text.
kono
parents:
diff changeset
60 -- 20 Dec 94 SAIC Replaced three unnecessary extension
kono
parents:
diff changeset
61 -- aggregates with simple aggregates.
kono
parents:
diff changeset
62 -- 16 Oct 95 SAIC Fixed bugs for ACVC 2.0.1
kono
parents:
diff changeset
63 --
kono
parents:
diff changeset
64 --!
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 ----------------------------------------------------------------- C390003_1
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 with Ada.Tags;
kono
parents:
diff changeset
69 package C390003_1 is -- Vehicle
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 type TC_Keys is (Veh, MC, Tand, Car, Q, Truk, Heavy);
kono
parents:
diff changeset
72 type States is (Good, Flat, Worn);
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 type Wheel_List is array(Positive range <>) of States;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type Object(Wheels: Positive) is tagged record
kono
parents:
diff changeset
77 Wheel_State : Wheel_List(1..Wheels);
kono
parents:
diff changeset
78 end record;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure TC_Validate( It: Object; Key: TC_Keys );
kono
parents:
diff changeset
81 procedure TC_Validate( It: Object'Class; The_Tag: Ada.Tags.Tag );
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 procedure Create( The_Vehicle : in out Object; Tyres : in States );
kono
parents:
diff changeset
84 procedure Rotate( The_Vehicle : in out Object );
kono
parents:
diff changeset
85 function Wheels( The_Vehicle : Object ) return Positive;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 end C390003_1; -- Vehicle;
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 ----------------------------------------------------------------- C390003_2
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 with C390003_1;
kono
parents:
diff changeset
92 package C390003_2 is -- Motivators
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 package Vehicle renames C390003_1;
kono
parents:
diff changeset
95 subtype Bicycle is Vehicle.Object(2); -- constrained subtype
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 type Motorcycle is new Bicycle with record
kono
parents:
diff changeset
98 Displacement : Natural;
kono
parents:
diff changeset
99 end record;
kono
parents:
diff changeset
100 procedure TC_Validate( It: Motorcycle; Key: Vehicle.TC_Keys );
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 type Tandem is new Bicycle with null record;
kono
parents:
diff changeset
103 procedure TC_Validate( It: Tandem; Key: Vehicle.TC_Keys );
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 type Car is new Vehicle.Object(4) with -- extended, constrained
kono
parents:
diff changeset
106 record
kono
parents:
diff changeset
107 Displacement : Natural;
kono
parents:
diff changeset
108 end record;
kono
parents:
diff changeset
109 procedure TC_Validate( It: Car; Key: Vehicle.TC_Keys );
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 type Truck is new Vehicle.Object with -- extended, unconstrained
kono
parents:
diff changeset
112 record
kono
parents:
diff changeset
113 Tare : Natural;
kono
parents:
diff changeset
114 end record;
kono
parents:
diff changeset
115 procedure TC_Validate( It: Truck; Key: Vehicle.TC_Keys );
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 end C390003_2; -- Motivators;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 ----------------------------------------------------------------- C390003_3
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 with C390003_1;
kono
parents:
diff changeset
122 with C390003_2;
kono
parents:
diff changeset
123 package C390003_3 is -- Special_Trucks
kono
parents:
diff changeset
124 package Vehicle renames C390003_1;
kono
parents:
diff changeset
125 package Motivators renames C390003_2;
kono
parents:
diff changeset
126 Max_Cars_On_Vehicle : constant := 6;
kono
parents:
diff changeset
127 type Cargo_Index is range 0..Max_Cars_On_Vehicle;
kono
parents:
diff changeset
128 type Cargo is array(Cargo_Index range 1..Max_Cars_On_Vehicle)
kono
parents:
diff changeset
129 of Motivators.Car;
kono
parents:
diff changeset
130 type Auto_Carrier is new Motivators.Truck(18) with
kono
parents:
diff changeset
131 record
kono
parents:
diff changeset
132 Load_Count : Cargo_Index := 0;
kono
parents:
diff changeset
133 Payload : Cargo;
kono
parents:
diff changeset
134 end record;
kono
parents:
diff changeset
135 procedure TC_Validate( It: Auto_Carrier; Key: Vehicle.TC_Keys );
kono
parents:
diff changeset
136 procedure Load ( The_Car : in Motivators.Car;
kono
parents:
diff changeset
137 Onto : in out Auto_Carrier);
kono
parents:
diff changeset
138 procedure Unload( The_Car : out Motivators.Car;
kono
parents:
diff changeset
139 Off_of : in out Auto_Carrier);
kono
parents:
diff changeset
140 end C390003_3;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 ----------------------------------------------------------------- C390003_4
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 with C390003_1;
kono
parents:
diff changeset
145 with C390003_2;
kono
parents:
diff changeset
146 package C390003_4 is -- James_Bond
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 package Vehicle renames C390003_1;
kono
parents:
diff changeset
149 package Motivators renames C390003_2;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 type Q_Machine is new Vehicle.Object(4) with record
kono
parents:
diff changeset
152 Car_Part : Motivators.Car;
kono
parents:
diff changeset
153 Bike_Part : Motivators.Motorcycle;
kono
parents:
diff changeset
154 end record;
kono
parents:
diff changeset
155 procedure TC_Validate( It: Q_Machine; Key: Vehicle.TC_Keys );
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 end C390003_4;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 ----------------------------------------------------------------- C390003_1
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 with Report;
kono
parents:
diff changeset
162 with Ada.Tags;
kono
parents:
diff changeset
163 package body C390003_1 is -- Vehicle
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 function "="(A,B: Ada.Tags.Tag) return Boolean renames Ada.Tags."=";
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 procedure TC_Validate( It: Object; Key: TC_Keys ) is
kono
parents:
diff changeset
168 begin
kono
parents:
diff changeset
169 if Key /= Veh then
kono
parents:
diff changeset
170 Report.Failed("Expected Veh Key");
kono
parents:
diff changeset
171 end if;
kono
parents:
diff changeset
172 end TC_Validate;
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 procedure TC_Validate( It: Object'Class; The_Tag: Ada.Tags.Tag ) is
kono
parents:
diff changeset
175 begin
kono
parents:
diff changeset
176 if It'Tag /= The_Tag then
kono
parents:
diff changeset
177 Report.Failed("Unexpected Tag for classwide formal");
kono
parents:
diff changeset
178 end if;
kono
parents:
diff changeset
179 end TC_Validate;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 procedure Create( The_Vehicle : in out Object; Tyres : in States ) is
kono
parents:
diff changeset
182 begin
kono
parents:
diff changeset
183 The_Vehicle.Wheel_State := ( others => Tyres );
kono
parents:
diff changeset
184 end Create;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 function Wheels( The_Vehicle : Object ) return Positive is
kono
parents:
diff changeset
187 begin
kono
parents:
diff changeset
188 return The_Vehicle.Wheels;
kono
parents:
diff changeset
189 end Wheels;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 procedure Rotate( The_Vehicle : in out Object ) is
kono
parents:
diff changeset
192 Push : States;
kono
parents:
diff changeset
193 Pulled : States
kono
parents:
diff changeset
194 := The_Vehicle.Wheel_State(The_Vehicle.Wheel_State'Last);
kono
parents:
diff changeset
195 begin
kono
parents:
diff changeset
196 for Finger in
kono
parents:
diff changeset
197 The_Vehicle.Wheel_State'First..The_Vehicle.Wheel_State'Last loop
kono
parents:
diff changeset
198 Push := The_Vehicle.Wheel_State(Finger);
kono
parents:
diff changeset
199 The_Vehicle.Wheel_State(Finger) := Pulled;
kono
parents:
diff changeset
200 Pulled := Push;
kono
parents:
diff changeset
201 end loop;
kono
parents:
diff changeset
202 end Rotate;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 end C390003_1; -- Vehicle;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 ----------------------------------------------------------------- C390003_2
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 with Ada.Tags;
kono
parents:
diff changeset
209 with Report;
kono
parents:
diff changeset
210 package body C390003_2 is -- Motivators
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 function "="(A,B: Ada.Tags.Tag) return Boolean renames Ada.Tags."=";
kono
parents:
diff changeset
213 function "="(A,B: Vehicle.TC_Keys) return Boolean renames Vehicle."=";
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 procedure TC_Validate( It: Motorcycle; Key: Vehicle.TC_Keys ) is
kono
parents:
diff changeset
216 begin
kono
parents:
diff changeset
217 if Key /= Vehicle.MC then
kono
parents:
diff changeset
218 Report.Failed("Expected MC Key");
kono
parents:
diff changeset
219 end if;
kono
parents:
diff changeset
220 end TC_Validate;
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 procedure TC_Validate( It: Tandem; Key: Vehicle.TC_Keys ) is
kono
parents:
diff changeset
223 begin
kono
parents:
diff changeset
224 if Key /= Vehicle.Tand then
kono
parents:
diff changeset
225 Report.Failed("Expected Tand Key");
kono
parents:
diff changeset
226 end if;
kono
parents:
diff changeset
227 end TC_Validate;
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 procedure TC_Validate( It: Car; Key: Vehicle.TC_Keys ) is
kono
parents:
diff changeset
230 begin
kono
parents:
diff changeset
231 if Key /= Vehicle.Car then
kono
parents:
diff changeset
232 Report.Failed("Expected Car Key");
kono
parents:
diff changeset
233 end if;
kono
parents:
diff changeset
234 end TC_Validate;
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 procedure TC_Validate( It: Truck; Key: Vehicle.TC_Keys ) is
kono
parents:
diff changeset
237 begin
kono
parents:
diff changeset
238 if Key /= Vehicle.Truk then
kono
parents:
diff changeset
239 Report.Failed("Expected Truk Key");
kono
parents:
diff changeset
240 end if;
kono
parents:
diff changeset
241 end TC_Validate;
kono
parents:
diff changeset
242 end C390003_2; -- Motivators;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 ----------------------------------------------------------------- C390003_3
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 with Ada.Tags;
kono
parents:
diff changeset
247 with Report;
kono
parents:
diff changeset
248 package body C390003_3 is -- Special_Trucks
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 function "="(A,B: Ada.Tags.Tag) return Boolean renames Ada.Tags."=";
kono
parents:
diff changeset
251 function "="(A,B: Vehicle.TC_Keys) return Boolean renames Vehicle."=";
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 procedure TC_Validate( It: Auto_Carrier; Key: Vehicle.TC_Keys ) is
kono
parents:
diff changeset
254 begin
kono
parents:
diff changeset
255 if Key /= Vehicle.Heavy then
kono
parents:
diff changeset
256 Report.Failed("Expected Heavy Key");
kono
parents:
diff changeset
257 end if;
kono
parents:
diff changeset
258 end TC_Validate;
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 procedure Load ( The_Car : in Motivators.Car;
kono
parents:
diff changeset
261 Onto : in out Auto_Carrier) is
kono
parents:
diff changeset
262 begin
kono
parents:
diff changeset
263 Onto.Load_Count := Onto.Load_Count +1;
kono
parents:
diff changeset
264 Onto.Payload(Onto.Load_Count) := The_Car;
kono
parents:
diff changeset
265 end Load;
kono
parents:
diff changeset
266 procedure Unload( The_Car : out Motivators.Car;
kono
parents:
diff changeset
267 Off_of : in out Auto_Carrier) is
kono
parents:
diff changeset
268 begin
kono
parents:
diff changeset
269 The_Car := Off_of.Payload(Off_of.Load_Count);
kono
parents:
diff changeset
270 Off_of.Load_Count := Off_of.Load_Count -1;
kono
parents:
diff changeset
271 end Unload;
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 end C390003_3;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 ----------------------------------------------------------------- C390003_4
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 with Report, Ada.Tags;
kono
parents:
diff changeset
278 package body C390003_4 is -- James_Bond
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 function "="(A,B: Ada.Tags.Tag) return Boolean renames Ada.Tags."=";
kono
parents:
diff changeset
281 function "="(A,B: Vehicle.TC_Keys) return Boolean renames Vehicle."=";
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 procedure TC_Validate( It: Q_Machine; Key: Vehicle.TC_Keys ) is
kono
parents:
diff changeset
284 begin
kono
parents:
diff changeset
285 if Key /= Vehicle.Q then
kono
parents:
diff changeset
286 Report.Failed("Expected Q Key");
kono
parents:
diff changeset
287 end if;
kono
parents:
diff changeset
288 end TC_Validate;
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 end C390003_4;
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 ------------------------------------------------------------------- C390003
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 with Report;
kono
parents:
diff changeset
295 with C390003_1;
kono
parents:
diff changeset
296 with C390003_2;
kono
parents:
diff changeset
297 with C390003_3;
kono
parents:
diff changeset
298 with C390003_4;
kono
parents:
diff changeset
299 procedure C390003 is
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 package Vehicle renames C390003_1; use Vehicle;
kono
parents:
diff changeset
302 package Motivators renames C390003_2;
kono
parents:
diff changeset
303 package Special_Trucks renames C390003_3;
kono
parents:
diff changeset
304 package James_Bond renames C390003_4;
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 -- The cast, in order of complexity:
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 Pennys_Bike : Motivators.Bicycle;
kono
parents:
diff changeset
309 Weekender : Motivators.Tandem;
kono
parents:
diff changeset
310 Qs_Moped : Motivators.Motorcycle;
kono
parents:
diff changeset
311 Ms_Limo : Motivators.Car;
kono
parents:
diff changeset
312 Yard_Van : Motivators.Truck(8);
kono
parents:
diff changeset
313 Specter_X : Special_Trucks.Auto_Carrier;
kono
parents:
diff changeset
314 Gen_II : James_Bond.Q_Machine;
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 -- Check compatibility with the corresponding class wide type.
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 procedure Vehicle_Shop( It : in out Vehicle.Object'Class;
kono
parents:
diff changeset
320 Key : in Vehicle.TC_Keys ) is
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 -- Check that Subtype'Class is defined for tagged subtypes.
kono
parents:
diff changeset
323 procedure Bike_Shop( Bike: in out Motivators.Bicycle'Class ) is
kono
parents:
diff changeset
324 begin
kono
parents:
diff changeset
325 -- Dispatch to appropriate TC_Validate
kono
parents:
diff changeset
326 Vehicle.TC_Validate( Bike, Key );
kono
parents:
diff changeset
327 end Bike_Shop;
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 begin
kono
parents:
diff changeset
330 Vehicle.TC_Validate( It, Key );
kono
parents:
diff changeset
331 if Vehicle.Wheels( It ) = 2 then
kono
parents:
diff changeset
332 Bike_Shop( It ); -- only call Bike_Shop when It has 2 wheels
kono
parents:
diff changeset
333 end if;
kono
parents:
diff changeset
334 end Vehicle_Shop;
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 begin -- Main test procedure.
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 Report.Test ("C390003", "Check that for a subtype S of a tagged type " &
kono
parents:
diff changeset
339 "T, S'Class denotes a class-wide subtype. Check that " &
kono
parents:
diff changeset
340 "T'Tag denotes the tag of the type T, and that, for a " &
kono
parents:
diff changeset
341 "class-wide tagged type X, X'Tag denotes the tag of X. " &
kono
parents:
diff changeset
342 "Check that the tags of stand alone objects, record and " &
kono
parents:
diff changeset
343 "array components, aggregates, and formal parameters " &
kono
parents:
diff changeset
344 "identify their type. Check that the tag of a value of a " &
kono
parents:
diff changeset
345 "formal parameter is that of the actual parameter, even " &
kono
parents:
diff changeset
346 "if the actual is passed by a view conversion" );
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 -- Check that the tags of stand alone objects, record and array
kono
parents:
diff changeset
349 -- components, aggregates, and formal parameters identify their type.
kono
parents:
diff changeset
350 -- Check that the tag of a value of a formal parameter is that of the
kono
parents:
diff changeset
351 -- actual parameter, even if the actual is passed by a view conversion.
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 Vehicle_Shop( Pennys_Bike, Veh );
kono
parents:
diff changeset
354 Vehicle_Shop( Weekender, Tand );
kono
parents:
diff changeset
355 Vehicle_Shop( Qs_Moped, MC );
kono
parents:
diff changeset
356 Vehicle_Shop( Ms_Limo, Car );
kono
parents:
diff changeset
357 Vehicle_Shop( Yard_Van, Truk );
kono
parents:
diff changeset
358 Vehicle_Shop( Specter_X, Heavy );
kono
parents:
diff changeset
359 Vehicle_Shop( Specter_X.Payload(1), Car );
kono
parents:
diff changeset
360 Vehicle_Shop( Gen_II, Q );
kono
parents:
diff changeset
361 Vehicle_Shop( Gen_II.Car_Part, Car );
kono
parents:
diff changeset
362 Vehicle_Shop( Gen_II.Bike_Part, MC );
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 Vehicle.TC_Validate( Pennys_Bike, Vehicle.Object'Tag );
kono
parents:
diff changeset
365 Vehicle.TC_Validate( Weekender, Motivators.Tandem'Tag );
kono
parents:
diff changeset
366 Vehicle.TC_Validate( Qs_Moped, Motivators.Motorcycle'Tag );
kono
parents:
diff changeset
367 Vehicle.TC_Validate( Ms_Limo, Motivators.Car'Tag );
kono
parents:
diff changeset
368 Vehicle.TC_Validate( Yard_Van, Motivators.Truck'Tag );
kono
parents:
diff changeset
369 Vehicle.TC_Validate( Specter_X, Special_Trucks.Auto_Carrier'Tag );
kono
parents:
diff changeset
370 Vehicle.TC_Validate( Specter_X.Payload(1), Motivators.Car'Tag );
kono
parents:
diff changeset
371 Vehicle.TC_Validate( Gen_II, James_Bond.Q_Machine'Tag );
kono
parents:
diff changeset
372 Vehicle.TC_Validate( Gen_II.Car_Part, Motivators.Car'Tag );
kono
parents:
diff changeset
373 Vehicle.TC_Validate( Gen_II.Bike_Part, Motivators.Motorcycle'Tag );
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 -- Check the tag generated for an aggregate.
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 Rentals: declare
kono
parents:
diff changeset
378 Mikes_Rental : Vehicle.Object'Class :=
kono
parents:
diff changeset
379 Vehicle.Object'( 3, (Good, Flat, Worn));
kono
parents:
diff changeset
380 Diannes_Car : Vehicle.Object'Class :=
kono
parents:
diff changeset
381 Motivators.Tandem'( Wheels => 2,
kono
parents:
diff changeset
382 Wheel_State => (Good, Good) );
kono
parents:
diff changeset
383 Jims_Bike : Vehicle.Object'Class :=
kono
parents:
diff changeset
384 Motivators.Motorcycle'( Pennys_Bike
kono
parents:
diff changeset
385 with Displacement => 350 );
kono
parents:
diff changeset
386 Bills_Limo : Vehicle.Object'Class :=
kono
parents:
diff changeset
387 Motivators.Car'( Wheels => 4,
kono
parents:
diff changeset
388 Wheel_State => (others => Good),
kono
parents:
diff changeset
389 Displacement => 282 );
kono
parents:
diff changeset
390 Alans_Car : Vehicle.Object'Class :=
kono
parents:
diff changeset
391 Motivators.Truck'( 18, (others => Worn),
kono
parents:
diff changeset
392 Tare => 5_500 );
kono
parents:
diff changeset
393 Pats_Truck : Vehicle.Object'Class := Specter_X;
kono
parents:
diff changeset
394 Keiths_Car : Vehicle.Object'Class := Gen_II;
kono
parents:
diff changeset
395 Isaacs_Bus : Vehicle.Object'Class := Keiths_Car;
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 begin
kono
parents:
diff changeset
398 Vehicle.TC_Validate( Mikes_Rental, Vehicle.Object'Tag );
kono
parents:
diff changeset
399 Vehicle.TC_Validate( Diannes_Car, Motivators.Tandem'Tag );
kono
parents:
diff changeset
400 Vehicle.TC_Validate( Jims_Bike, Motivators.Motorcycle'Tag );
kono
parents:
diff changeset
401 Vehicle.TC_Validate( Bills_Limo, Motivators.Car'Tag );
kono
parents:
diff changeset
402 Vehicle.TC_Validate( Alans_Car, Motivators.Truck'Tag );
kono
parents:
diff changeset
403 Vehicle.TC_Validate( Pats_Truck, Special_Trucks.Auto_Carrier'Tag );
kono
parents:
diff changeset
404 Vehicle.TC_Validate( Keiths_Car, James_Bond.Q_Machine'Tag );
kono
parents:
diff changeset
405 end Rentals;
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 -- Check the tag of parameters.
kono
parents:
diff changeset
408 -- Check that the tag is not affected by view conversion.
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 Vehicle.TC_Validate( Vehicle.Object( Gen_II ), James_Bond.Q_Machine'Tag );
kono
parents:
diff changeset
411 Vehicle.TC_Validate( Vehicle.Object( Ms_Limo ), Motivators.Car'Tag );
kono
parents:
diff changeset
412 Vehicle.TC_Validate( Motivators.Bicycle( Weekender ),
kono
parents:
diff changeset
413 Motivators.Tandem'Tag );
kono
parents:
diff changeset
414 Vehicle.TC_Validate( Motivators.Bicycle( Gen_II.Bike_Part ),
kono
parents:
diff changeset
415 Motivators.Motorcycle'Tag );
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 Report.Result;
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 end C390003;