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 record extension can be declared in the same package
28 -- as its parent, and that this parent may be a tagged record or a
29 -- record extension. Check that each derivative inherits all user-
30 -- defined primitive subprograms of its parent (including those that
31 -- its parent inherited), and that it may declare its own primitive
34 -- Check that predefined equality operators are defined for the root
37 -- Check that type conversion is defined from a type extension to its
38 -- parent, and that this parent itself may be a type extension.
41 -- Declare a root tagged type in a package specification. Declare two
42 -- primitive subprograms for the type.
44 -- Extend the root type with a record extension in the same package
45 -- specification. Declare a new primitive subprogram for the extension
46 -- (in addition to its two inherited subprograms).
48 -- Extend the extension with a record extension in the same package
49 -- specification. Declare a new primitive subprogram for this second
50 -- extension (in addition to its three inherited subprograms).
52 -- In the main program, declare operations for the root tagged type which
53 -- utilize aggregates and equality operators to verify the correctness
54 -- of the components. Overload these operations for the two type
55 -- extensions. Within each of these overloading operations, utilize type
56 -- conversion to call the parent's implementation of the same operation.
59 -- The following files comprise this test:
66 -- 06 Dec 94 SAIC ACVC 2.0
75 package Check_Alert_Values is
77 -- Declare functions to verify correctness of tagged record components
78 -- before and after calls to their primitive subprograms.
83 function Initial_Values_Okay (A : in C3900010.Alert_Type)
86 function Bad_Final_Values (A : in C3900010.Alert_Type)
92 function Initial_Values_Okay (LA : in C3900010.Low_Alert_Type)
95 function Bad_Final_Values (LA : in C3900010.Low_Alert_Type)
101 function Initial_Values_Okay (MA : in C3900010.Medium_Alert_Type)
104 function Bad_Final_Values (MA : in C3900010.Medium_Alert_Type)
108 end Check_Alert_Values;
111 --==========================================================--
114 package body Check_Alert_Values is
117 function Initial_Values_Okay (A : in C3900010.Alert_Type)
119 use type C3900010.Alert_Type;
120 begin -- "=" operator availability.
121 return (A = (Arrival_Time => C3900010.Default_Time,
122 Display_On => C3900010.Null_Device));
123 end Initial_Values_Okay;
126 function Initial_Values_Okay (LA : in C3900010.Low_Alert_Type)
128 begin -- Type conversion.
129 return (Initial_Values_Okay (C3900010.Alert_Type (LA)) and
131 end Initial_Values_Okay;
134 function Initial_Values_Okay (MA : in C3900010.Medium_Alert_Type)
136 use type C3900010.Person_Enum;
137 begin -- Type conversion.
138 return (Initial_Values_Okay (C3900010.Low_Alert_Type (MA)) and
139 MA.Action_Officer = C3900010.Nobody);
140 end Initial_Values_Okay;
143 function Bad_Final_Values (A : in C3900010.Alert_Type)
145 use type C3900010.Alert_Type;
146 begin -- "/=" operator availability.
147 return (A /= (Arrival_Time => C3900010.Alert_Time,
148 Display_On => C3900010.Null_Device));
149 end Bad_Final_Values;
152 function Bad_Final_Values (LA : in C3900010.Low_Alert_Type)
154 use type C3900010.Low_Alert_Type;
155 begin -- "=" operator availability.
156 return not ( LA = (Arrival_Time => C3900010.Alert_Time,
157 Display_On => C3900010.Teletype,
159 end Bad_Final_Values;
162 function Bad_Final_Values (MA : in C3900010.Medium_Alert_Type)
164 use type C3900010.Medium_Alert_Type;
165 begin -- "/=" operator availability.
166 return ( MA /= (C3900010.Alert_Time,
169 C3900010.Duty_Officer) );
170 end Bad_Final_Values;
173 end Check_Alert_Values;
176 --==========================================================--
179 use Check_Alert_Values;
182 Root_Alarm : C3900010.Alert_Type;
183 Low_Alarm : C3900010.Low_Alert_Type;
184 Medium_Alarm : C3900010.Medium_Alert_Type;
188 Report.Test ("C390001", "Primitive operation inheritance by type " &
189 "extensions: all extensions declared in same package " &
193 -- Check root tagged type:
195 if Initial_Values_Okay (Root_Alarm) then
196 Handle (Root_Alarm); -- Explicitly declared.
197 Display (Root_Alarm); -- Explicitly declared.
199 if Bad_Final_Values (Root_Alarm) then
200 Report.Failed ("Wrong results after Alert_Type calls");
203 Report.Failed ("Wrong initial values for Alert_Type");
207 -- Check record extension of root tagged type:
209 if Initial_Values_Okay (Low_Alarm) then
210 Handle (Low_Alarm); -- Inherited.
211 Low_Alarm.Display_On := Teletype;
212 Display (Low_Alarm); -- Inherited.
213 Low_Alarm.Level := Level_Of (Low_Alarm); -- Explicitly declared.
215 if Bad_Final_Values (Low_Alarm) then
216 Report.Failed ("Wrong results after Low_Alert_Type calls");
219 Report.Failed ("Wrong initial values for Low_Alert_Type");
223 -- Check record extension of record extension:
225 if Initial_Values_Okay (Medium_Alarm) then
226 Handle (Medium_Alarm); -- Inherited twice.
227 Medium_Alarm.Display_On := Console;
228 Display (Medium_Alarm); -- Inherited twice.
229 Medium_Alarm.Level := Level_Of (Medium_Alarm); -- Inherited.
230 Assign_Officer (Medium_Alarm, Duty_Officer); -- Explicitly declared.
232 if Bad_Final_Values (Medium_Alarm) then
233 Report.Failed ("Wrong results after Medium_Alert_Type calls");
236 Report.Failed ("Wrong initial values for Medium_Alert_Type");
240 -- Check final display counts:
242 if C3900010.Display_Count_For /= (Null_Device => 1,
247 Report.Failed ("Wrong final values for display counts");