annotate gcc/testsuite/ada/acats/tests/c3/c390004.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 -- C390004.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 tags of allocated objects correctly identify the
kono
parents:
diff changeset
28 -- type of the allocated object. Check that the tag corresponds
kono
parents:
diff changeset
29 -- correctly to the value resulting from both normal and view
kono
parents:
diff changeset
30 -- conversion. Check that the tags of accessed values designating
kono
parents:
diff changeset
31 -- aliased objects correctly identify the type of the object. Check
kono
parents:
diff changeset
32 -- that the tag of a function result correctly evaluates. Check this
kono
parents:
diff changeset
33 -- for class-wide functions. The tag of a class-wide function result
kono
parents:
diff changeset
34 -- should be the tag appropriate to the actual value returned, not the
kono
parents:
diff changeset
35 -- tag of the ancestor type.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- TEST DESCRIPTION:
kono
parents:
diff changeset
38 -- This test defines a class hierarchy of types, with reference
kono
parents:
diff changeset
39 -- semantics (an access type to the class-wide type). Similar in
kono
parents:
diff changeset
40 -- structure to C392005, this test checks that dynamic allocation does
kono
parents:
diff changeset
41 -- not adversely impact the tagging of types.
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 -- CHANGE HISTORY:
kono
parents:
diff changeset
45 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 --!
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 package C390004_1 is -- DMV
kono
parents:
diff changeset
50 type Equipment is ( T_Veh, T_Car, T_Con, T_Jep );
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 type Vehicle is tagged record
kono
parents:
diff changeset
53 Wheels : Natural := 4;
kono
parents:
diff changeset
54 Parked : Boolean := False;
kono
parents:
diff changeset
55 end record;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 function Wheels ( It: Vehicle ) return Natural;
kono
parents:
diff changeset
58 procedure Park ( It: in out Vehicle );
kono
parents:
diff changeset
59 procedure UnPark ( It: in out Vehicle );
kono
parents:
diff changeset
60 procedure Set_Wheels( It: in out Vehicle; To_Count: in Natural );
kono
parents:
diff changeset
61 procedure TC_Check ( It: in Vehicle; To_Equip: in Equipment );
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 type Car is new Vehicle with record
kono
parents:
diff changeset
64 Passengers : Natural := 0;
kono
parents:
diff changeset
65 end record;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 function Passengers ( It: Car ) return Natural;
kono
parents:
diff changeset
68 procedure Load_Passengers( It: in out Car; To_Count: in Natural );
kono
parents:
diff changeset
69 procedure Park ( It: in out Car );
kono
parents:
diff changeset
70 procedure TC_Check ( It: in Car; To_Equip: in Equipment );
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 type Convertible is new Car with record
kono
parents:
diff changeset
73 Top_Up : Boolean := True;
kono
parents:
diff changeset
74 end record;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Top_Up ( It: Convertible ) return Boolean;
kono
parents:
diff changeset
77 procedure Lower_Top( It: in out Convertible );
kono
parents:
diff changeset
78 procedure Park ( It: in out Convertible );
kono
parents:
diff changeset
79 procedure Raise_Top( It: in out Convertible );
kono
parents:
diff changeset
80 procedure TC_Check ( It: in Convertible; To_Equip: in Equipment );
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 type Jeep is new Convertible with record
kono
parents:
diff changeset
83 Windshield_Up : Boolean := True;
kono
parents:
diff changeset
84 end record;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function Windshield_Up ( It: Jeep ) return Boolean;
kono
parents:
diff changeset
87 procedure Lower_Windshield( It: in out Jeep );
kono
parents:
diff changeset
88 procedure Park ( It: in out Jeep );
kono
parents:
diff changeset
89 procedure Raise_Windshield( It: in out Jeep );
kono
parents:
diff changeset
90 procedure TC_Check ( It: in Jeep; To_Equip: in Equipment );
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 end C390004_1;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 with Report;
kono
parents:
diff changeset
95 package body C390004_1 is
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Set_Wheels( It: in out Vehicle; To_Count: in Natural ) is
kono
parents:
diff changeset
98 begin
kono
parents:
diff changeset
99 It.Wheels := To_Count;
kono
parents:
diff changeset
100 end Set_Wheels;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 function Wheels( It: Vehicle ) return Natural is
kono
parents:
diff changeset
103 begin
kono
parents:
diff changeset
104 return It.Wheels;
kono
parents:
diff changeset
105 end Wheels;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Park ( It: in out Vehicle ) is
kono
parents:
diff changeset
108 begin
kono
parents:
diff changeset
109 It.Parked := True;
kono
parents:
diff changeset
110 end Park;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 procedure UnPark ( It: in out Vehicle ) is
kono
parents:
diff changeset
113 begin
kono
parents:
diff changeset
114 It.Parked := False;
kono
parents:
diff changeset
115 end UnPark;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure TC_Check ( It: in Vehicle; To_Equip: in Equipment ) is
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 if To_Equip /= T_Veh then
kono
parents:
diff changeset
120 Report.Failed ("Failed, called Vehicle for "
kono
parents:
diff changeset
121 & Equipment'Image(To_Equip));
kono
parents:
diff changeset
122 end if;
kono
parents:
diff changeset
123 end TC_Check;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 procedure TC_Check ( It: in Car; To_Equip: in Equipment ) is
kono
parents:
diff changeset
126 begin
kono
parents:
diff changeset
127 if To_Equip /= T_Car then
kono
parents:
diff changeset
128 Report.Failed ("Failed, called Car for "
kono
parents:
diff changeset
129 & Equipment'Image(To_Equip));
kono
parents:
diff changeset
130 end if;
kono
parents:
diff changeset
131 end TC_Check;
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 procedure TC_Check ( It: in Convertible; To_Equip: in Equipment ) is
kono
parents:
diff changeset
134 begin
kono
parents:
diff changeset
135 if To_Equip /= T_Con then
kono
parents:
diff changeset
136 Report.Failed ("Failed, called Convertible for "
kono
parents:
diff changeset
137 & Equipment'Image(To_Equip));
kono
parents:
diff changeset
138 end if;
kono
parents:
diff changeset
139 end TC_Check;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 procedure TC_Check ( It: in Jeep; To_Equip: in Equipment ) is
kono
parents:
diff changeset
142 begin
kono
parents:
diff changeset
143 if To_Equip /= T_Jep then
kono
parents:
diff changeset
144 Report.Failed ("Failed, called Jeep for "
kono
parents:
diff changeset
145 & Equipment'Image(To_Equip));
kono
parents:
diff changeset
146 end if;
kono
parents:
diff changeset
147 end TC_Check;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 procedure Load_Passengers( It: in out Car; To_Count: in Natural ) is
kono
parents:
diff changeset
150 begin
kono
parents:
diff changeset
151 It.Passengers := To_Count;
kono
parents:
diff changeset
152 UnPark( It );
kono
parents:
diff changeset
153 end Load_Passengers;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 procedure Park( It: in out Car ) is
kono
parents:
diff changeset
156 begin
kono
parents:
diff changeset
157 It.Passengers := 0;
kono
parents:
diff changeset
158 Park( Vehicle( It ) );
kono
parents:
diff changeset
159 end Park;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 function Passengers( It: Car ) return Natural is
kono
parents:
diff changeset
162 begin
kono
parents:
diff changeset
163 return It.Passengers;
kono
parents:
diff changeset
164 end Passengers;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 procedure Raise_Top( It: in out Convertible ) is
kono
parents:
diff changeset
167 begin
kono
parents:
diff changeset
168 It.Top_Up := True;
kono
parents:
diff changeset
169 end Raise_Top;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 procedure Lower_Top( It: in out Convertible ) is
kono
parents:
diff changeset
172 begin
kono
parents:
diff changeset
173 It.Top_Up := False;
kono
parents:
diff changeset
174 end Lower_Top;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 function Top_Up ( It: Convertible ) return Boolean is
kono
parents:
diff changeset
177 begin
kono
parents:
diff changeset
178 return It.Top_Up;
kono
parents:
diff changeset
179 end Top_Up;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 procedure Park ( It: in out Convertible ) is
kono
parents:
diff changeset
182 begin
kono
parents:
diff changeset
183 It.Top_Up := True;
kono
parents:
diff changeset
184 Park( Car( It ) );
kono
parents:
diff changeset
185 end Park;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 procedure Raise_Windshield( It: in out Jeep ) is
kono
parents:
diff changeset
188 begin
kono
parents:
diff changeset
189 It.Windshield_Up := True;
kono
parents:
diff changeset
190 end Raise_Windshield;
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 procedure Lower_Windshield( It: in out Jeep ) is
kono
parents:
diff changeset
193 begin
kono
parents:
diff changeset
194 It.Windshield_Up := False;
kono
parents:
diff changeset
195 end Lower_Windshield;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 function Windshield_Up( It: Jeep ) return Boolean is
kono
parents:
diff changeset
198 begin
kono
parents:
diff changeset
199 return It.Windshield_Up;
kono
parents:
diff changeset
200 end Windshield_Up;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 procedure Park( It: in out Jeep ) is
kono
parents:
diff changeset
203 begin
kono
parents:
diff changeset
204 It.Windshield_Up := True;
kono
parents:
diff changeset
205 Park( Convertible( It ) );
kono
parents:
diff changeset
206 end Park;
kono
parents:
diff changeset
207 end C390004_1;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 with Report;
kono
parents:
diff changeset
210 with Ada.Tags;
kono
parents:
diff changeset
211 with C390004_1;
kono
parents:
diff changeset
212 procedure C390004 is
kono
parents:
diff changeset
213 package DMV renames C390004_1;
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 The_Vehicle : aliased DMV.Vehicle;
kono
parents:
diff changeset
216 The_Car : aliased DMV.Car;
kono
parents:
diff changeset
217 The_Convertible : aliased DMV.Convertible;
kono
parents:
diff changeset
218 The_Jeep : aliased DMV.Jeep;
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 type C_Reference is access all DMV.Car'Class;
kono
parents:
diff changeset
221 type V_Reference is access all DMV.Vehicle'Class;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 Designator : V_Reference;
kono
parents:
diff changeset
224 Storage : Natural;
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 procedure Valet( It: in out DMV.Vehicle'Class ) is
kono
parents:
diff changeset
227 begin
kono
parents:
diff changeset
228 DMV.Park( It );
kono
parents:
diff changeset
229 end Valet;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 procedure TC_Match( Object: DMV.Vehicle'Class;
kono
parents:
diff changeset
232 Taglet: Ada.Tags.Tag;
kono
parents:
diff changeset
233 Where : String ) is
kono
parents:
diff changeset
234 use Ada.Tags;
kono
parents:
diff changeset
235 begin
kono
parents:
diff changeset
236 if Object'Tag /= Taglet then
kono
parents:
diff changeset
237 Report.Failed("Tag mismatch: " & Where);
kono
parents:
diff changeset
238 end if;
kono
parents:
diff changeset
239 end TC_Match;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 procedure Parking_Validation( It: DMV.Vehicle; TC_Message: String ) is
kono
parents:
diff changeset
242 begin
kono
parents:
diff changeset
243 if DMV.Wheels( It ) /= 1 or not It.Parked then
kono
parents:
diff changeset
244 Report.Failed ("Failed Vehicle " & TC_Message);
kono
parents:
diff changeset
245 end if;
kono
parents:
diff changeset
246 end Parking_Validation;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 procedure Parking_Validation( It: DMV.Car; TC_Message: String ) is
kono
parents:
diff changeset
249 begin
kono
parents:
diff changeset
250 if DMV.Wheels( It ) /= 2 or DMV.Passengers( It ) /= 0
kono
parents:
diff changeset
251 or not It.Parked then
kono
parents:
diff changeset
252 Report.Failed ("Failed Car " & TC_Message);
kono
parents:
diff changeset
253 end if;
kono
parents:
diff changeset
254 end Parking_Validation;
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 procedure Parking_Validation( It: DMV.Convertible;
kono
parents:
diff changeset
257 TC_Message: String ) is
kono
parents:
diff changeset
258 begin
kono
parents:
diff changeset
259 if DMV.Wheels( It ) /= 3 or DMV.Passengers( It ) /= 0
kono
parents:
diff changeset
260 or not DMV.Top_Up( It ) or not It.Parked then
kono
parents:
diff changeset
261 Report.Failed ("Failed Convertible " & TC_Message);
kono
parents:
diff changeset
262 end if;
kono
parents:
diff changeset
263 end Parking_Validation;
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 procedure Parking_Validation( It: DMV.Jeep; TC_Message: String ) is
kono
parents:
diff changeset
266 begin
kono
parents:
diff changeset
267 if DMV.Wheels( It ) /= 4 or DMV.Passengers( It ) /= 0
kono
parents:
diff changeset
268 or not DMV.Top_Up( It ) or not DMV.Windshield_Up( It )
kono
parents:
diff changeset
269 or not It.Parked then
kono
parents:
diff changeset
270 Report.Failed ("Failed Jeep " & TC_Message);
kono
parents:
diff changeset
271 end if;
kono
parents:
diff changeset
272 end Parking_Validation;
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 function Wash( It: V_Reference; TC_Expect : Ada.Tags.Tag )
kono
parents:
diff changeset
275 return DMV.Vehicle'Class is
kono
parents:
diff changeset
276 This_Machine : DMV.Vehicle'Class := It.all;
kono
parents:
diff changeset
277 begin
kono
parents:
diff changeset
278 TC_Match( It.all, TC_Expect, "Class-wide object in Wash" );
kono
parents:
diff changeset
279 Storage := DMV.Wheels( This_Machine );
kono
parents:
diff changeset
280 return This_Machine;
kono
parents:
diff changeset
281 end Wash;
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 function Wash( It: C_Reference; TC_Expect : Ada.Tags.Tag )
kono
parents:
diff changeset
284 return DMV.Car'Class is
kono
parents:
diff changeset
285 This_Machine : DMV.Car'Class := It.all;
kono
parents:
diff changeset
286 begin
kono
parents:
diff changeset
287 TC_Match( It.all, TC_Expect, "Class-wide object in Wash" );
kono
parents:
diff changeset
288 Storage := DMV.Wheels( This_Machine );
kono
parents:
diff changeset
289 return This_Machine;
kono
parents:
diff changeset
290 end Wash;
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 begin
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 Report.Test( "C390004", "Check that the tags of allocated objects "
kono
parents:
diff changeset
295 & "correctly identify the type of the allocated "
kono
parents:
diff changeset
296 & "object. Check that tags resulting from "
kono
parents:
diff changeset
297 & "normal and view conversions. Check tags of "
kono
parents:
diff changeset
298 & "accessed values designating aliased objects. "
kono
parents:
diff changeset
299 & "Check function result tags" );
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 DMV.Set_Wheels( The_Vehicle, 1 );
kono
parents:
diff changeset
302 DMV.Set_Wheels( The_Car, 2 );
kono
parents:
diff changeset
303 DMV.Set_Wheels( The_Convertible, 3 );
kono
parents:
diff changeset
304 DMV.Set_Wheels( The_Jeep, 4 );
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 Valet( The_Vehicle );
kono
parents:
diff changeset
307 Valet( The_Car );
kono
parents:
diff changeset
308 Valet( The_Convertible );
kono
parents:
diff changeset
309 Valet( The_Jeep );
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 Parking_Validation( The_Vehicle, "setup" );
kono
parents:
diff changeset
312 Parking_Validation( The_Car, "setup" );
kono
parents:
diff changeset
313 Parking_Validation( The_Convertible, "setup" );
kono
parents:
diff changeset
314 Parking_Validation( The_Jeep, "setup" );
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316 -- Check that the tags of allocated objects correctly identify the type
kono
parents:
diff changeset
317 -- of the allocated object.
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 Designator := new DMV.Vehicle;
kono
parents:
diff changeset
320 DMV.TC_Check( Designator.all, DMV.T_Veh );
kono
parents:
diff changeset
321 TC_Match( Designator.all, DMV.Vehicle'Tag, "allocated Vehicle" );
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 Designator := new DMV.Car;
kono
parents:
diff changeset
324 DMV.TC_Check( Designator.all, DMV.T_Car );
kono
parents:
diff changeset
325 TC_Match( Designator.all, DMV.Car'Tag, "allocated Car");
kono
parents:
diff changeset
326
kono
parents:
diff changeset
327 Designator := new DMV.Convertible;
kono
parents:
diff changeset
328 DMV.TC_Check( Designator.all, DMV.T_Con );
kono
parents:
diff changeset
329 TC_Match( Designator.all, DMV.Convertible'Tag, "allocated Convertible" );
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 Designator := new DMV.Jeep;
kono
parents:
diff changeset
332 DMV.TC_Check( Designator.all, DMV.T_Jep );
kono
parents:
diff changeset
333 TC_Match( Designator.all, DMV.Jeep'Tag, "allocated Jeep" );
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 -- Check that view conversion causes the correct dispatch
kono
parents:
diff changeset
336 DMV.TC_Check( DMV.Vehicle( The_Jeep ), DMV.T_Veh );
kono
parents:
diff changeset
337 DMV.TC_Check( DMV.Car( The_Jeep ), DMV.T_Car );
kono
parents:
diff changeset
338 DMV.TC_Check( DMV.Convertible( The_Jeep ), DMV.T_Con );
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 -- And that view conversion does not change the tag
kono
parents:
diff changeset
341 TC_Match( DMV.Vehicle( The_Jeep ), DMV.Jeep'Tag, "View Conv Veh" );
kono
parents:
diff changeset
342 TC_Match( DMV.Car( The_Jeep ), DMV.Jeep'Tag, "View Conv Car" );
kono
parents:
diff changeset
343 TC_Match( DMV.Convertible( The_Jeep ), DMV.Jeep'Tag, "View Conv Jep" );
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 -- Check that the tags of accessed values designating aliased objects
kono
parents:
diff changeset
346 -- correctly identify the type of the object.
kono
parents:
diff changeset
347 Designator := The_Vehicle'Access;
kono
parents:
diff changeset
348 DMV.TC_Check( Designator.all, DMV.T_Veh );
kono
parents:
diff changeset
349 TC_Match( Designator.all, DMV.Vehicle'Tag, "aliased Vehicle" );
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 Designator := The_Car'Access;
kono
parents:
diff changeset
352 DMV.TC_Check( Designator.all, DMV.T_Car );
kono
parents:
diff changeset
353 TC_Match( Designator.all, DMV.Car'Tag, "aliased Car" );
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 Designator := The_Convertible'Access;
kono
parents:
diff changeset
356 DMV.TC_Check( Designator.all, DMV.T_Con );
kono
parents:
diff changeset
357 TC_Match( Designator.all, DMV.Convertible'Tag, "aliased Convertible" );
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 Designator := The_Jeep'Access;
kono
parents:
diff changeset
360 DMV.TC_Check( Designator.all, DMV.T_Jep );
kono
parents:
diff changeset
361 TC_Match( Designator.all, DMV.Jeep'Tag, "aliased Jeep" );
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 -- Check that the tag of a function result correctly evaluates.
kono
parents:
diff changeset
364 -- Check this for class-wide functions. The tag of a class-wide
kono
parents:
diff changeset
365 -- function result should be the tag appropriate to the actual value
kono
parents:
diff changeset
366 -- returned, not the tag of the ancestor type.
kono
parents:
diff changeset
367 Function_Check: declare
kono
parents:
diff changeset
368 A_Vehicle : V_Reference := new DMV.Vehicle'( The_Vehicle );
kono
parents:
diff changeset
369 A_Car : C_Reference := new DMV.Car'( The_Car );
kono
parents:
diff changeset
370 A_Convertible : C_Reference := new DMV.Convertible'( The_Convertible );
kono
parents:
diff changeset
371 A_Jeep : C_Reference := new DMV.Jeep'( The_Jeep );
kono
parents:
diff changeset
372 begin
kono
parents:
diff changeset
373 DMV.Unpark( A_Vehicle.all );
kono
parents:
diff changeset
374 DMV.Load_Passengers( A_Car.all, 5 );
kono
parents:
diff changeset
375 DMV.Load_Passengers( A_Convertible.all, 6 );
kono
parents:
diff changeset
376 DMV.Load_Passengers( A_Jeep.all, 7 );
kono
parents:
diff changeset
377 DMV.Lower_Top( DMV.Convertible(A_Convertible.all) );
kono
parents:
diff changeset
378 DMV.Lower_Top( DMV.Jeep(A_Jeep.all) );
kono
parents:
diff changeset
379 DMV.Lower_Windshield( DMV.Jeep(A_Jeep.all) );
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 if DMV.Wheels( Wash( A_Jeep, DMV.Jeep'Tag ) ) /= 4
kono
parents:
diff changeset
382 or Storage /= 4 then
kono
parents:
diff changeset
383 Report.Failed("Did not correctly wash Jeep");
kono
parents:
diff changeset
384 end if;
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 if DMV.Wheels( Wash( A_Convertible, DMV.Convertible'Tag ) ) /= 3
kono
parents:
diff changeset
387 or Storage /= 3 then
kono
parents:
diff changeset
388 Report.Failed("Did not correctly wash Convertible");
kono
parents:
diff changeset
389 end if;
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 if DMV.Wheels( Wash( A_Car, DMV.Car'Tag ) ) /= 2
kono
parents:
diff changeset
392 or Storage /= 2 then
kono
parents:
diff changeset
393 Report.Failed("Did not correctly wash Car");
kono
parents:
diff changeset
394 end if;
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 if DMV.Wheels( Wash( A_Vehicle, DMV.Vehicle'Tag ) ) /= 1
kono
parents:
diff changeset
397 or Storage /= 1 then
kono
parents:
diff changeset
398 Report.Failed("Did not correctly wash Vehicle");
kono
parents:
diff changeset
399 end if;
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 end Function_Check;
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 Report.Result;
kono
parents:
diff changeset
404 end C390004;