1 |
149 |
jeremybenn |
-- C730001.A
|
2 |
|
|
--
|
3 |
|
|
-- Grant of Unlimited Rights
|
4 |
|
|
--
|
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
|
14 |
|
|
-- to do so.
|
15 |
|
|
--
|
16 |
|
|
-- DISCLAIMER
|
17 |
|
|
--
|
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.
|
24 |
|
|
--*
|
25 |
|
|
--
|
26 |
|
|
-- OBJECTIVE:
|
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
|
34 |
|
|
-- type. Check both dispatching and non-dispatching cases.
|
35 |
|
|
--
|
36 |
|
|
-- TEST DESCRIPTION:
|
37 |
|
|
-- Consider:
|
38 |
|
|
--
|
39 |
|
|
-- package P is
|
40 |
|
|
-- type Ancestor is tagged ...
|
41 |
|
|
-- procedure Op (P1: Ancestor; P2: Boolean := True);
|
42 |
|
|
-- end P;
|
43 |
|
|
--
|
44 |
|
|
-- with P;
|
45 |
|
|
-- package Q is
|
46 |
|
|
-- type Derived is new P.Ancestor with ...
|
47 |
|
|
-- procedure Op (X: Ancestor; Y: Boolean := False);
|
48 |
|
|
-- end Q;
|
49 |
|
|
--
|
50 |
|
|
-- with P, Q;
|
51 |
|
|
-- package R is
|
52 |
|
|
-- type Priv_Ext is new P.Ancestor with private; -- (A)
|
53 |
|
|
-- -- Inherits procedure Op (P1: Priv_Ext; P2: Boolean := True);
|
54 |
|
|
-- -- But body executed is that of Q.Op.
|
55 |
|
|
-- private
|
56 |
|
|
-- type Priv_Ext is new Q.Derived with record ... -- (B)
|
57 |
|
|
-- end R;
|
58 |
|
|
--
|
59 |
|
|
-- The ancestor type in (A) differs from the parent type in (B); the
|
60 |
|
|
-- parent of the full type is descended from the ancestor type of the
|
61 |
|
|
-- private extension. For a call to Op (from outside the scope of the
|
62 |
|
|
-- full view) with an operand of type Priv_Ext, the formal parameter
|
63 |
|
|
-- names and default expression come from that of P.Op (the ancestor
|
64 |
|
|
-- type's version), but the body executed will be that of
|
65 |
|
|
-- Q.Op (the parent type's version)
|
66 |
|
|
--
|
67 |
|
|
-- One half of the test mirrors the above template, where an inherited
|
68 |
|
|
-- subprogram (Set_Display) is called using the formal parameter
|
69 |
|
|
-- name (C) and default parameter expression of the ancestor type's
|
70 |
|
|
-- version (type Clock), but the version of the body executed is from
|
71 |
|
|
-- the parent type.
|
72 |
|
|
--
|
73 |
|
|
-- The test also includes an examination of the dynamic evaluation
|
74 |
|
|
-- case, where correct body associations are required through dispatching
|
75 |
|
|
-- calls. As described for the non-dispatching case above, the formal
|
76 |
|
|
-- parameter name and default values of the ancestor type's (Phone)
|
77 |
|
|
-- version of the inherited subprogram (Answer) are used in the
|
78 |
|
|
-- dispatching call, but the body executed is from the parent type.
|
79 |
|
|
--
|
80 |
|
|
--
|
81 |
|
|
-- CHANGE HISTORY:
|
82 |
|
|
-- 06 Dec 94 SAIC ACVC 2.0
|
83 |
|
|
--
|
84 |
|
|
--!
|
85 |
|
|
|
86 |
|
|
package C730001_0 is
|
87 |
|
|
|
88 |
|
|
type Display_Kind is (None, Analog, Digital);
|
89 |
|
|
type Illumination_Type is (None, Light, Phosphorescence);
|
90 |
|
|
type Capability_Type is (Available, In_Use, Call_Waiting, Conference);
|
91 |
|
|
type Indicator_Type is (None, Light, Bell, Buzzer, Click, Modem);
|
92 |
|
|
|
93 |
|
|
type Clock is abstract tagged record -- ancestor type associated
|
94 |
|
|
Display : Display_Kind := None; -- with non-dispatching case.
|
95 |
|
|
Illumination : Illumination_Type := None;
|
96 |
|
|
end record;
|
97 |
|
|
|
98 |
|
|
type Phone is tagged record -- ancestor type associated
|
99 |
|
|
Status : Capability_Type := Available; -- with dispatching case.
|
100 |
|
|
Indicator : Indicator_Type := None;
|
101 |
|
|
end record;
|
102 |
|
|
|
103 |
|
|
-- The Set_Display procedure for type Clock implements a basic, no-frills
|
104 |
|
|
-- clock display.
|
105 |
|
|
procedure Set_Display (C : in out Clock;
|
106 |
|
|
Disp: in Display_Kind := Digital);
|
107 |
|
|
|
108 |
|
|
-- The Answer procedure for type Phone implements a phone status change
|
109 |
|
|
-- operation.
|
110 |
|
|
procedure Answer (The_Phone : in out Phone;
|
111 |
|
|
Ind : in Indicator_Type := Light);
|
112 |
|
|
-- ...Other general clock and/or phone operations (not specified in this
|
113 |
|
|
-- test scenario).
|
114 |
|
|
|
115 |
|
|
end C730001_0;
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
--==================================================================--
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
package body C730001_0 is
|
122 |
|
|
|
123 |
|
|
procedure Set_Display (C : in out Clock;
|
124 |
|
|
Disp: in Display_Kind := Digital) is
|
125 |
|
|
begin
|
126 |
|
|
C.Display := Disp;
|
127 |
|
|
C.Illumination := Light;
|
128 |
|
|
end Set_Display;
|
129 |
|
|
|
130 |
|
|
procedure Answer (The_Phone : in out Phone;
|
131 |
|
|
Ind : in Indicator_Type := Light) is
|
132 |
|
|
begin
|
133 |
|
|
The_Phone.Status := In_Use;
|
134 |
|
|
The_Phone.Indicator := Ind;
|
135 |
|
|
end Answer;
|
136 |
|
|
|
137 |
|
|
end C730001_0;
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
--==================================================================--
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
with C730001_0; use C730001_0;
|
144 |
|
|
package C730001_1 is
|
145 |
|
|
|
146 |
|
|
type Power_Supply_Type is (Spring, Battery, AC_Current);
|
147 |
|
|
type Speaker_Type is (None, Present, Adjustable, Stereo);
|
148 |
|
|
|
149 |
|
|
type Wall_Clock is new Clock with record
|
150 |
|
|
Power_Source : Power_Supply_Type := Spring;
|
151 |
|
|
end record;
|
152 |
|
|
|
153 |
|
|
type Office_Phone is new Phone with record
|
154 |
|
|
Speaker : Speaker_Type := Present;
|
155 |
|
|
end record;
|
156 |
|
|
|
157 |
|
|
-- Note: Both procedures below, parameter names and defaults differ from
|
158 |
|
|
-- parent's version.
|
159 |
|
|
|
160 |
|
|
-- The Set_Display procedure for type Wall_Clock improves upon the
|
161 |
|
|
-- basic Set_Display procedure of type Clock.
|
162 |
|
|
|
163 |
|
|
procedure Set_Display (WC: in out Wall_Clock;
|
164 |
|
|
D : in Display_Kind := Analog);
|
165 |
|
|
|
166 |
|
|
procedure Answer (OP : in out Office_Phone;
|
167 |
|
|
OI : in Indicator_Type := Buzzer);
|
168 |
|
|
|
169 |
|
|
-- ...Other wall clock and/or Office_Phone operations (not specified in
|
170 |
|
|
-- this test scenario).
|
171 |
|
|
|
172 |
|
|
end C730001_1;
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
--==================================================================--
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
package body C730001_1 is
|
179 |
|
|
|
180 |
|
|
-- Note: This body is the one that should be executed in the test block
|
181 |
|
|
-- below, not the version of the body corresponding to type Clock.
|
182 |
|
|
|
183 |
|
|
procedure Set_Display (WC: in out Wall_Clock;
|
184 |
|
|
D : in Display_Kind := Analog) is
|
185 |
|
|
begin
|
186 |
|
|
WC.Display := D;
|
187 |
|
|
WC.Illumination := Phosphorescence;
|
188 |
|
|
end Set_Display;
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
procedure Answer (OP : in out Office_Phone;
|
192 |
|
|
OI : in Indicator_Type := Buzzer) is
|
193 |
|
|
begin
|
194 |
|
|
OP.Status := Call_Waiting;
|
195 |
|
|
OP.Indicator := OI;
|
196 |
|
|
end Answer;
|
197 |
|
|
|
198 |
|
|
end C730001_1;
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
--==================================================================--
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
with C730001_0; use C730001_0;
|
205 |
|
|
with C730001_1; use C730001_1;
|
206 |
|
|
package C730001_2 is
|
207 |
|
|
|
208 |
|
|
type Alarm_Type is (Buzzer, Radio, Both);
|
209 |
|
|
type Video_Type is (None, TV_Monitor, Wall_Projection);
|
210 |
|
|
|
211 |
|
|
type Alarm_Clock is new Clock with private;
|
212 |
|
|
-- Inherits proc Set_Display (C : in out Clock;
|
213 |
|
|
-- Disp: in Display_Kind := Digital); -- (A)
|
214 |
|
|
--
|
215 |
|
|
-- Would also inherit other general clock operations (if present).
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
type Conference_Room_Phone is new Office_Phone with record
|
219 |
|
|
Display : Video_Type := TV_Monitor;
|
220 |
|
|
end record;
|
221 |
|
|
|
222 |
|
|
procedure Answer (CP : in out Conference_Room_Phone;
|
223 |
|
|
CI : in Indicator_Type := Modem);
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
function TC_Get_Display (C: Alarm_Clock) return Display_Kind;
|
227 |
|
|
function TC_Get_Display_Illumination (C: Alarm_Clock)
|
228 |
|
|
return Illumination_Type;
|
229 |
|
|
|
230 |
|
|
private
|
231 |
|
|
|
232 |
|
|
-- ...however, certain of the wall clock's operations (Set_Display, in
|
233 |
|
|
-- this example) improve on the implementations provided for the general
|
234 |
|
|
-- clock. We want to call the improved implementations, so we
|
235 |
|
|
-- derive from Wall_Clock in the private part.
|
236 |
|
|
|
237 |
|
|
type Alarm_Clock is new Wall_Clock with record
|
238 |
|
|
Alarm : Alarm_Type := Buzzer;
|
239 |
|
|
end record;
|
240 |
|
|
|
241 |
|
|
-- Inherits proc Set_Display (WC: in out Wall_Clock;
|
242 |
|
|
-- D : in Display_Kind := Analog); -- (B)
|
243 |
|
|
|
244 |
|
|
-- The implicit Set_Display at (B) overrides the implicit Set_Display at
|
245 |
|
|
-- (A), but only within the scope of the full view.
|
246 |
|
|
--
|
247 |
|
|
-- Outside the scope of the full view, only (A) is visible, so calls
|
248 |
|
|
-- from outside the scope will get the formal parameter names and default
|
249 |
|
|
-- from (A). Both inside and outside the scope, however, the body executed
|
250 |
|
|
-- will be that corresponding to Set_Display of the parent type.
|
251 |
|
|
|
252 |
|
|
end C730001_2;
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
--==================================================================--
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
package body C730001_2 is
|
259 |
|
|
|
260 |
|
|
procedure Answer (CP : in out Conference_Room_Phone;
|
261 |
|
|
CI : in Indicator_Type := Modem)is
|
262 |
|
|
begin
|
263 |
|
|
CP.Status := Conference;
|
264 |
|
|
CP.Indicator := CI;
|
265 |
|
|
end Answer;
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
function TC_Get_Display (C: Alarm_Clock) return Display_Kind is
|
269 |
|
|
begin
|
270 |
|
|
return C.Display;
|
271 |
|
|
end TC_Get_Display;
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
function TC_Get_Display_Illumination (C: Alarm_Clock)
|
275 |
|
|
return Illumination_Type is
|
276 |
|
|
begin
|
277 |
|
|
return C.Illumination;
|
278 |
|
|
end TC_Get_Display_Illumination;
|
279 |
|
|
|
280 |
|
|
end C730001_2;
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
--==================================================================--
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
with C730001_0; use C730001_0;
|
287 |
|
|
with C730001_1; use C730001_1;
|
288 |
|
|
with C730001_2; use C730001_2;
|
289 |
|
|
|
290 |
|
|
package C730001_3 is
|
291 |
|
|
|
292 |
|
|
-- Types extended from the ancestor (Phone) type in the specification.
|
293 |
|
|
|
294 |
|
|
type Secure_Phone_Type is new Phone with private;
|
295 |
|
|
type Auditorium_Phone_Type is new Phone with private;
|
296 |
|
|
-- Inherit versions of Answer from ancestor (Phone).
|
297 |
|
|
|
298 |
|
|
function TC_Get_Phone_Status (P : Phone'Class) return Capability_Type;
|
299 |
|
|
function TC_Get_Indicator (P : Phone'Class) return Indicator_Type;
|
300 |
|
|
|
301 |
|
|
private
|
302 |
|
|
|
303 |
|
|
-- Types extended from descendents of Phone_Type in the private part.
|
304 |
|
|
|
305 |
|
|
type Secure_Phone_Type is new Office_Phone with record
|
306 |
|
|
Scrambled_Communication : Boolean := True;
|
307 |
|
|
end record;
|
308 |
|
|
|
309 |
|
|
type Auditorium_Phone_Type is new Conference_Room_Phone with record
|
310 |
|
|
Volume_Control : Boolean := True;
|
311 |
|
|
end record;
|
312 |
|
|
|
313 |
|
|
end C730001_3;
|
314 |
|
|
|
315 |
|
|
--==================================================================--
|
316 |
|
|
|
317 |
|
|
package body C730001_3 is
|
318 |
|
|
|
319 |
|
|
function TC_Get_Phone_Status (P : Phone'Class) return Capability_Type is
|
320 |
|
|
begin
|
321 |
|
|
return P.Status;
|
322 |
|
|
end TC_Get_Phone_Status;
|
323 |
|
|
|
324 |
|
|
function TC_Get_Indicator (P : Phone'Class) return Indicator_Type is
|
325 |
|
|
begin
|
326 |
|
|
return P.Indicator;
|
327 |
|
|
end TC_Get_Indicator;
|
328 |
|
|
|
329 |
|
|
end C730001_3;
|
330 |
|
|
|
331 |
|
|
--==================================================================--
|
332 |
|
|
|
333 |
|
|
with C730001_0; use C730001_0;
|
334 |
|
|
with C730001_1; use C730001_1;
|
335 |
|
|
with C730001_2; use C730001_2;
|
336 |
|
|
with C730001_3; use C730001_3;
|
337 |
|
|
|
338 |
|
|
with Report;
|
339 |
|
|
|
340 |
|
|
procedure C730001 is
|
341 |
|
|
begin
|
342 |
|
|
|
343 |
|
|
Report.Test ("C730001","Check that the full view of a private extension " &
|
344 |
|
|
"may be derived indirectly from the ancestor " &
|
345 |
|
|
"type. Check that, for a primitive subprogram " &
|
346 |
|
|
"of the private extension that is inherited from " &
|
347 |
|
|
"the ancestor type and not overridden, the " &
|
348 |
|
|
"formal parameter names and default expressions " &
|
349 |
|
|
"come from the corresponding primitive " &
|
350 |
|
|
"subprogram of the ancestor type, while the body " &
|
351 |
|
|
"comes from that of the parent type");
|
352 |
|
|
|
353 |
|
|
Test_Block:
|
354 |
|
|
declare
|
355 |
|
|
|
356 |
|
|
Alarm : Alarm_Clock;
|
357 |
|
|
Hot_Line : Secure_Phone_Type;
|
358 |
|
|
TeleConference_Phone : Auditorium_Phone_Type;
|
359 |
|
|
|
360 |
|
|
begin
|
361 |
|
|
|
362 |
|
|
-- Evaluate non-dispatching case:
|
363 |
|
|
|
364 |
|
|
-- Call Set_Display using formal parameter name from
|
365 |
|
|
-- C730001_0.Set_Display.
|
366 |
|
|
-- Give no 2nd parameter so that default expression must be used.
|
367 |
|
|
|
368 |
|
|
Set_Display (C => Alarm);
|
369 |
|
|
|
370 |
|
|
-- The value of the Display component should equal Digital, which is
|
371 |
|
|
-- the default value from the ancestor's version of Set_Display,
|
372 |
|
|
-- and not the default value from the parent's version of Set_Display.
|
373 |
|
|
|
374 |
|
|
if TC_Get_Display (Alarm) /= Digital then
|
375 |
|
|
Report.Failed ("Default expression for ancestor op not used " &
|
376 |
|
|
"in non-dispatching case");
|
377 |
|
|
end if;
|
378 |
|
|
|
379 |
|
|
-- However, the value of the Illumination component should equal
|
380 |
|
|
-- Phosphorescence, which is assigned in the parent type's version of
|
381 |
|
|
-- the body of Set_Display.
|
382 |
|
|
|
383 |
|
|
if TC_Get_Display_Illumination (Alarm) /= Phosphorescence then
|
384 |
|
|
Report.Failed ("Wrong body was executed in non-dispatching case");
|
385 |
|
|
end if;
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
-- Evaluate dispatching case:
|
389 |
|
|
declare
|
390 |
|
|
|
391 |
|
|
Hot_Line : Secure_Phone_Type;
|
392 |
|
|
TeleConference_Phone : Auditorium_Phone_Type;
|
393 |
|
|
|
394 |
|
|
procedure Answer_The_Phone (P : in out Phone'Class) is
|
395 |
|
|
begin
|
396 |
|
|
-- Give no 2nd parameter so that default expression must be used.
|
397 |
|
|
Answer (P);
|
398 |
|
|
end Answer_The_Phone;
|
399 |
|
|
|
400 |
|
|
begin
|
401 |
|
|
|
402 |
|
|
Answer_The_Phone (Hot_Line);
|
403 |
|
|
Answer_The_Phone (TeleConference_Phone);
|
404 |
|
|
|
405 |
|
|
-- The value of the Indicator field shold equal "Light", the default
|
406 |
|
|
-- value from the ancestor's version of Answer, and not the default
|
407 |
|
|
-- from either of the parent versions of Answer.
|
408 |
|
|
|
409 |
|
|
if TC_Get_Indicator(Hot_Line) /= Light or
|
410 |
|
|
TC_Get_Indicator(TeleConference_Phone) /= Light
|
411 |
|
|
then
|
412 |
|
|
Report.Failed("Default expression from ancestor operation " &
|
413 |
|
|
"not used in dispatching case");
|
414 |
|
|
end if;
|
415 |
|
|
|
416 |
|
|
-- However, the value of the Status component should equal
|
417 |
|
|
-- Call_Waiting or Conference respectively, based on the assignment
|
418 |
|
|
-- in the parent type's version of the body of Answer.
|
419 |
|
|
|
420 |
|
|
if TC_Get_Phone_Status(Hot_Line) /= Call_Waiting then
|
421 |
|
|
Report.Failed("Wrong body executed in dispatching case - 1");
|
422 |
|
|
end if;
|
423 |
|
|
|
424 |
|
|
if TC_Get_Phone_Status(TeleConference_Phone) /= Conference then
|
425 |
|
|
Report.Failed("Wrong body executed in dispatching case - 2");
|
426 |
|
|
end if;
|
427 |
|
|
|
428 |
|
|
end;
|
429 |
|
|
|
430 |
|
|
exception
|
431 |
|
|
when others => Report.Failed ("Exception raised in Test_Block");
|
432 |
|
|
end Test_Block;
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
Report.Result;
|
436 |
|
|
|
437 |
|
|
end C730001;
|