3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that the full view of a private extension may be derived
28 -- indirectly from the ancestor type (i.e., the parent type of the full
29 -- type may be any descendant of the ancestor type). Check that, for
30 -- a primitive subprogram of the private extension that is inherited from
31 -- the ancestor type and not overridden, the formal parameter names and
32 -- default expressions come from the corresponding primitive subprogram
33 -- of the ancestor type, while the body comes from that of the parent
35 -- Check for a case where the parent type is derived from the ancestor
36 -- type through a series of types produced by generic instantiations.
37 -- Examine both the static and dynamic binding cases.
43 -- type Ancestor is tagged ...
44 -- procedure Op (P1: Ancestor; P2: Boolean := True);
49 -- type T is new P.Ancestor with private;
51 -- type Enhanced is new T with private;
52 -- procedure Op (A: Enhanced; B: Boolean := True);
53 -- -- other specific procedures...
55 -- type Enhanced is new T with ...
59 -- package N is new Gen1 (P.Ancestor);
63 -- type T is new N.Enhanced with private;
65 -- type Enhanced_Again is new T with private;
66 -- procedure Op (X: Enhanced_Again; Y: Boolean := False);
67 -- -- other specific procedures...
69 -- type Enhanced_Again is new T with ...
73 -- package Q is new Gen2 (N.Enhanced);
77 -- type Priv_Ext is new P.Ancestor with private; -- (A)
78 -- -- Inherits procedure Op (P1: Priv_Ext; P2: Boolean := True);
79 -- -- But body executed is that of Q.Op.
81 -- type Priv_Ext is new Q.Enhanced_Again with record ... -- (B)
84 -- The ancestor type in (A) differs from the parent type in (B); the
85 -- parent of the full type is descended from the ancestor type of the
86 -- private extension, in this case through a series of types produced
87 -- by generic instantiations. Gen1 redefines the implementation of Op
88 -- for any type that has one. N is an instance of Gen1 for the ancestor
89 -- type. Gen2 again redefines the implementation of Op for any type that
90 -- has one. Q is an instance of Gen2 for the extension of the P.Ancestor
91 -- declared in N. Both N and Q could define other operations which we
92 -- don't want to be available in R. For a call to Op (from outside the
93 -- scope of the full view) with an operand of type R.Priv_Ext, the body
94 -- executed will be that of Q.Op (the parent type's version), but the
95 -- formal parameter names and default expression come from that of P.Op
96 -- (the ancestor type's version).
100 -- 06 Dec 94 SAIC ACVC 2.0
101 -- 27 Feb 97 CTA.PWB Added elaboration pragmas.
106 type Hours_Type
is range 0..1000;
107 type Personnel_Type
is range 0..10;
108 type Specialist_ID
is (Manny
, Moe
, Jack
, Curly
, Joe
, Larry
);
110 type Engine_Type
is tagged record
111 Ave_Repair_Time
: Hours_Type
:= 0; -- Default init. for
112 Personnel_Required
: Personnel_Type
:= 0; -- component fields.
113 Specialist
: Specialist_ID
:= Manny
;
116 procedure Routine_Maintenance
(Engine
: in out Engine_Type
;
117 Specialist
: in Specialist_ID
:= Moe
);
119 -- The Routine_Maintenance procedure implements the processing required
124 --==================================================================--
126 package body C730002_0
is
128 procedure Routine_Maintenance
(Engine
: in out Engine_Type
;
129 Specialist
: in Specialist_ID
:= Moe
) is
131 Engine
.Ave_Repair_Time
:= 3;
132 Engine
.Personnel_Required
:= 1;
133 Engine
.Specialist
:= Specialist
;
134 end Routine_Maintenance
;
138 --==================================================================--
140 with C730002_0
; use C730002_0
;
142 type T
is new C730002_0
.Engine_Type
with private;
145 -- This generic package contains types/procedures specific to engines
146 -- of the diesel variety.
148 type Repair_Facility_Type
is (On_Site
, Repair_Shop
, Factory
);
150 type Diesel_Series
is new T
with private;
152 procedure Routine_Maintenance
(Eng
: in out Diesel_Series
;
153 Spec_Req
: in Specialist_ID
:= Jack
);
155 -- Other diesel specific operations... (not required in this test).
159 type Diesel_Series
is new T
with record
160 Repair_Facility_Required
: Repair_Facility_Type
:= On_Site
;
165 --==================================================================--
167 package body C730002_1
is
169 procedure Routine_Maintenance
(Eng
: in out Diesel_Series
;
170 Spec_Req
: in Specialist_ID
:= Jack
) is
172 Eng
.Ave_Repair_Time
:= 6;
173 Eng
.Personnel_Required
:= 2;
174 Eng
.Specialist
:= Spec_Req
;
175 Eng
.Repair_Facility_Required
:= On_Site
;
176 end Routine_Maintenance
;
180 --==================================================================--
184 pragma Elaborate
(C730002_1
);
185 package C730002_2
is new C730002_1
(C730002_0
.Engine_Type
);
187 --==================================================================--
189 with C730002_0
; use C730002_0
;
190 with C730002_2
; use C730002_2
;
192 type T
is new C730002_2
.Diesel_Series
with private;
195 type Time_Of_Operation_Type
is range 0..100_000
;
197 type Electric_Series
is new T
with private;
199 procedure Routine_Maintenance
(E
: in out Electric_Series
;
200 SR
: in Specialist_ID
:= Curly
);
202 -- Other electric specific operations... (not required in this test).
206 type Electric_Series
is new T
with record
207 Mean_Time_Between_Repair
: Time_Of_Operation_Type
:= 0;
212 --==================================================================--
214 package body C730002_3
is
216 procedure Routine_Maintenance
(E
: in out Electric_Series
;
217 SR
: in Specialist_ID
:= Curly
) is
219 E
.Ave_Repair_Time
:= 9;
220 E
.Personnel_Required
:= 3;
222 E
.Mean_Time_Between_Repair
:= 1000;
223 end Routine_Maintenance
;
227 --==================================================================--
231 pragma Elaborate
(C730002_3
);
232 package C730002_4
is new C730002_3
(C730002_2
.Diesel_Series
);
234 --==================================================================--
236 with C730002_0
; use C730002_0
;
237 with C730002_4
; use C730002_4
;
241 type Inspection_Type
is (AAA
, MIL_STD
, NRC
);
243 type Nuclear_Series
is new Engine_Type
with private; -- (A)
245 -- Inherits procedure Routine_Maintenance from ancestor; does not override.
246 -- (Engine : in out Nuclear_Series;
247 -- Specialist : in Specialist_ID := Moe);
248 -- But body executed will be that of C730002_4.Routine_Maintenance,
251 function TC_Specialist
(E
: Nuclear_Series
) return Specialist_ID
;
252 function TC_Personnel_Required
(E
: Nuclear_Series
) return Personnel_Type
;
253 function TC_Time_Required
(E
: Nuclear_Series
) return Hours_Type
;
255 -- Dispatching subprogram.
256 procedure Maintain_The_Engine
(The_Engine
: in out Engine_Type
'Class);
260 type Nuclear_Series
is new Electric_Series
with record -- (B)
261 Inspector_Rep
: Inspection_Type
:= NRC
;
264 -- The ancestor type is used in the type extension (A), while the parent
265 -- of the full type (B) is a descendent of the ancestor type, through a
266 -- series of types produced by generic instantiation.
270 --==================================================================--
272 package body C730002_5
is
274 function TC_Specialist
(E
: Nuclear_Series
) return Specialist_ID
is
279 function TC_Personnel_Required
(E
: Nuclear_Series
)
280 return Personnel_Type
is
282 return E
.Personnel_Required
;
283 end TC_Personnel_Required
;
285 function TC_Time_Required
(E
: Nuclear_Series
) return Hours_Type
is
287 return E
.Ave_Repair_Time
;
288 end TC_Time_Required
;
290 -- Dispatching subprogram.
291 procedure Maintain_The_Engine
(The_Engine
: in out Engine_Type
'Class) is
293 Routine_Maintenance
(The_Engine
);
294 end Maintain_The_Engine
;
299 --==================================================================--
302 with C730002_0
; use C730002_0
;
303 with C730002_2
; use C730002_2
;
304 with C730002_4
; use C730002_4
;
305 with C730002_5
; use C730002_5
;
310 Report
.Test
("C730002", "Check that the full view of a private " &
311 "extension may be derived indirectly from " &
312 "the ancestor type. Check for a case where " &
313 "the parent type is derived from the ancestor " &
314 "type through a series of types produced by " &
315 "generic instantiations");
319 Nuclear_Drive
: Nuclear_Series
;
320 Warp_Drive
: Nuclear_Series
;
323 -- Non-Dispatching Case:
324 -- Call Routine_Maintenance using formal parameter name from
325 -- C730002_0.Routine_Maintenance (ancestor version).
326 -- Give no second parameter so that the default expression must be
329 Routine_Maintenance
(Engine
=> Nuclear_Drive
);
331 -- The value of the Specialist component should equal "Moe",
332 -- which is the default value from the ancestor's version of
333 -- Routine_Maintenance, and not the default value from the parent's
334 -- version of Routine_Maintenance.
336 if TC_Specialist
(Nuclear_Drive
) /= Moe
then
338 ("Default expression for ancestor op not used " &
339 " - non-dispatching case");
342 -- However the value of the Ave_Repair_Time and Personnel_Required
343 -- components should be those assigned in the parent type's version
344 -- of the body of Routine_Maintenance.
345 -- Note: Only components associated with the ancestor type are
346 -- evaluated for the purposes of this test.
348 if TC_Personnel_Required
(Nuclear_Drive
) /= 3 or
349 TC_Time_Required
(Nuclear_Drive
) /= 9
351 Report
.Failed
("Wrong body was executed - non-dispatching case");
355 -- Use a dispatching subprogram to ensure that the correct body is
358 Maintain_The_Engine
(Warp_Drive
);
360 -- The resulting assignments to the fields of the Warp_Drive variable
361 -- should be the same as those of the Nuclear_Drive above, indicating
362 -- that the body of the parent version of the inherited subprogram
365 if TC_Specialist
(Warp_Drive
) /= Moe
then
367 ("Default expression for ancestor op not used - dispatching case");
370 if TC_Personnel_Required
(Nuclear_Drive
) /= 3 or
371 TC_Time_Required
(Nuclear_Drive
) /= 9
373 Report
.Failed
("Wrong body was executed - dispatching case");
378 when others => Report
.Failed
("Exception raised in Test_Block");