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 subprograms inherited from tagged derivations, which are
28 -- subsequently redefined for the derived type, are available to the
29 -- package defining the new class via view conversion. Check
30 -- that operations performed on objects using view conversion do not
31 -- affect the extended fields. Check that visible operations not masked
32 -- by the deriving package remain available to the client, and do not
33 -- affect the extended fields.
36 -- This test declares a tagged type, with a constructor operation,
37 -- derives a type from that tagged type, and declares a constructor
38 -- operation which masks the inherited operation. It then tests
39 -- that the correct constructor is called, and that the extended
40 -- part of the derived type remains untouched as appropriate.
44 -- 06 Dec 94 SAIC ACVC 2.0
45 -- 19 Dec 94 SAIC Removed RM references from objective text.
46 -- 04 Jan 94 SAIC Fixed objective typo, removed dead code.
54 type Vehicle
is tagged private;
56 procedure Create
( The_Vehicle
: out Vehicle
; TC_Flag
: Natural );
57 procedure Start
( The_Vehicle
: in out Vehicle
);
61 type Vehicle
is tagged record
67 package body C392004_1
is
68 procedure Create
( The_Vehicle
: out Vehicle
; TC_Flag
: Natural ) is
71 when 1 => null; -- expected flag for this subprogram
73 Report
.Failed
("Called Vehicle Create");
75 The_Vehicle
:= (Engine_On
=> False);
78 procedure Start
( The_Vehicle
: in out Vehicle
) is
80 The_Vehicle
.Engine_On
:= True;
85 ----------------------------------------------------------------------------
90 type Car
is new C392004_1
.Vehicle
with record
91 Convertible
: Boolean;
95 procedure Create
( The_Car
: out Car
; TC_Flag
: Natural );
97 type Limo
is new Car
with null record;
99 procedure Create
( The_Limo
: out Limo
; TC_Flag
: Natural );
103 ----------------------------------------------------------------------------
106 package body C392004_2
is
108 procedure Create
( The_Car
: out Car
; TC_Flag
: Natural ) is
111 when 2 => null; -- expected flag for this subprogram
112 when others => Report
.Failed
("Called Car Create");
114 C392004_1
.Create
( C392004_1
.Vehicle
(The_Car
), 1);
115 The_Car
.Convertible
:= False;
118 procedure Create
( The_Limo
: out Limo
; TC_Flag
: Natural ) is
121 when 3 => null; -- expected flag for this subprogram
122 when others => Report
.Failed
("Called Limo Create");
124 C392004_1
.Create
( C392004_1
.Vehicle
(The_Limo
), 1);
125 The_Limo
.Convertible
:= True;
130 ----------------------------------------------------------------------------
133 with C392004_1
; use C392004_1
;
134 with C392004_2
; use C392004_2
;
140 procedure TC_Assert
( Is_True
: Boolean; Message
: String ) is
143 Report
.Failed
(Message
);
147 begin -- Main test procedure.
149 Report
.Test
("C392004", "Check subprogram inheritance & visibility " &
150 "for derived tagged types" );
152 My_Car
.Convertible
:= False;
153 Create
( Vehicle
( My_Car
), 1 );
154 TC_Assert
( not My_Car
.Convertible
, "Altered descendent component 1");
156 Create
( Your_Car
, 3 );
157 TC_Assert
( Your_Car
.Convertible
, "Did not set inherited component 2");
159 My_Car
.Convertible
:= True;
160 Create
( Vehicle
( My_Car
), 1 );
161 TC_Assert
( My_Car
.Convertible
, "Altered descendent component 3");
164 TC_Assert
( not My_Car
.Convertible
, "Did not set extending component 4");
166 My_Car
.Convertible
:= False;
167 Start
( Vehicle
( My_Car
) );
168 TC_Assert
( not My_Car
.Convertible
, "Altered descendent component 5");
171 TC_Assert
( not My_Car
.Convertible
, "Altered unreferenced component 6");
173 Your_Car
.Convertible
:= False;
174 Start
( Vehicle
( Your_Car
) );
175 TC_Assert
( not Your_Car
.Convertible
, "Altered descendent component 7");
178 TC_Assert
( not Your_Car
.Convertible
, "Altered unreferenced component 8");
180 My_Car
.Convertible
:= True;
181 Start
( Vehicle
( My_Car
) );
182 TC_Assert
( My_Car
.Convertible
, "Altered descendent component 9");
185 TC_Assert
( My_Car
.Convertible
, "Altered unreferenced component 10");