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 a tagged base type may be declared, and derived
28 -- from in simple, private and extended forms. (Overlaps with C390B04)
29 -- Check that the package Ada.Tags is present and correctly implemented.
30 -- Check for the correct operation of Expanded_Name, External_Tag and
31 -- Internal_Tag within that package. Check that the exception Tag_Error
32 -- is correctly raised on calling Internal_Tag with bad input.
35 -- This test declares a tagged type, and derives three types from it.
36 -- These types are then used to test the presence and function of the
41 -- 06 Dec 94 SAIC ACVC 2.0
42 -- 19 Dec 94 SAIC Removed RM references from objective text.
43 -- 27 Jan 96 SAIC Update RM references for 2.1
54 type Object
is tagged limited private; -- ancestor type
55 procedure Create
( The_Vehicle
: in out Object
; Wheels
: in Natural );
56 function Wheels
( The_Vehicle
: Object
) return Natural;
60 type Object
is tagged limited record
61 Wheel_Count
: Natural := 0;
68 type Bicycle
is new Vehicle
.Object
with null record; -- simple
70 type Car
is new Vehicle
.Object
with record -- extended
71 Convertible
: Boolean;
74 type Truck
is new Vehicle
.Object
with private; -- private
78 type Truck
is new Vehicle
.Object
with record
84 package body Vehicle
is
86 procedure Create
( The_Vehicle
: in out Object
; Wheels
: in Natural ) is
88 The_Vehicle
.Wheel_Count
:= Wheels
;
91 function Wheels
( The_Vehicle
: Object
) return Natural is
93 return The_Vehicle
.Wheel_Count
;
98 function TC_ID_Tag
( Tag
: in Ada
.Tags
.Tag
) return Ada
.Tags
.Tag
is
100 return Ada
.Tags
.Internal_Tag
( Ada
.Tags
.External_Tag
( Tag
) );
101 Report
.Comment
("This message intentionally blank.");
104 procedure Check_Tags
( Machine
: in Vehicle
.Object
'Class;
105 Expected_Name
: in String;
106 External_Tag
: in String ) is
107 The_Tag
: constant Ada
.Tags
.Tag
:= Machine
'Tag;
108 use type Ada
.Tags
.Tag
;
110 if Ada
.Tags
.Expanded_Name
(The_Tag
) /= Expected_Name
then
111 Report
.Failed
("Failed in Check_Tags, Expanded_Name "
114 if Ada
.Tags
.External_Tag
(The_Tag
) /= External_Tag
then
115 Report
.Failed
("Failed in Check_Tags, External_Tag "
118 if Ada
.Tags
.Internal_Tag
(External_Tag
) /= The_Tag
then
119 Report
.Failed
("Failed in Check_Tags, Internal_Tag "
124 procedure Check_Exception
is
125 Boeing_777_Id
: Ada
.Tags
.Tag
;
127 Boeing_777_Id
:= Ada
.Tags
.Internal_Tag
("!@#$%^:*\/?"" not a tag!");
128 Report
.Failed
("Failed in Check_Exception, no exception");
129 Boeing_777_Id
:= TC_ID_Tag
( Boeing_777_Id
);
131 when Ada
.Tags
.Tag_Error
=> null;
133 Report
.Failed
("Failed in Check_Exception, wrong exception");
137 Two_Wheeler
: Bicycle
;
139 Eighteen_Wheeler
: Truck
;
141 begin -- Main test procedure.
143 Report
.Test
("C390002", "Check that a tagged type may be declared and " &
144 "derived from in simple, private and extended forms. " &
145 "Check package Ada.Tags" );
147 Create
( Two_Wheeler
, 2 );
148 Create
( Four_Wheeler
, 4 );
149 Create
( Eighteen_Wheeler
, 18 );
151 Check_Tags
( Machine
=> Two_Wheeler
,
152 Expected_Name
=> "C390002.MOTIVATORS.BICYCLE",
153 External_Tag
=> Bicycle
'External_Tag );
154 Check_Tags
( Machine
=> Four_Wheeler
,
155 Expected_Name
=> "C390002.MOTIVATORS.CAR",
156 External_Tag
=> Car
'External_Tag );
157 Check_Tags
( Machine
=> Eighteen_Wheeler
,
158 Expected_Name
=> "C390002.MOTIVATORS.TRUCK",
159 External_Tag
=> Truck
'External_Tag );