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 non-abstract primitive subprogram of an abstract
28 -- type can be called as a dispatching operation and that the body
29 -- of this subprogram can make a dispatching call to an abstract
30 -- operation of the corresponding abstract type.
33 -- This test expands on the class family defined in foundation F393A00
34 -- by deriving a new abstract type from the root abstract type "Object".
35 -- The subprograms defined for the new abstract type are then
36 -- appropriately overridden, and the test ultimately calls various
37 -- mixtures of these subprograms to check that the dispatching occurs
41 -- The following files comprise this test:
43 -- F393A00.A (foundation code)
48 -- 06 Dec 94 SAIC ACVC 2.0
49 -- 19 Dec 94 SAIC Removed ARM references from objective text.
50 -- 23 Oct 95 SAIC Fixed bugs for ACVC 2.0.1
54 ------------------------------------------------------------------- C393A03_0
59 type Counting_Object
is abstract new F393A00_1
.Object
with private;
60 -- inherits Initialize, Swap (abstract) and Create (abstract)
62 procedure Bump
( A_Counter
: in out Counting_Object
);
63 procedure Clear
( A_Counter
: in out Counting_Object
) is abstract;
64 procedure Zero
( A_Counter
: in out Counting_Object
);
65 function Value
( A_Counter
: Counting_Object
'Class ) return Natural;
69 type Counting_Object
is abstract new F393A00_1
.Object
with
76 -----------------------------------------------------------------------------
79 package body C393A03_0
is
81 procedure Bump
( A_Counter
: in out Counting_Object
) is
83 F393A00_0
.TC_Touch
('A');
84 A_Counter
.Tally
:= A_Counter
.Tally
+1;
87 procedure Zero
( A_Counter
: in out Counting_Object
) is
89 F393A00_0
.TC_Touch
('B');
91 -- dispatching call to abstract operation of Counting_Object
92 Clear
( Counting_Object
'Class(A_Counter
) );
98 function Value
( A_Counter
: Counting_Object
'Class ) return Natural is
100 F393A00_0
.TC_Touch
('C');
101 return A_Counter
.Tally
;
106 ------------------------------------------------------------------- C393A03_1
111 type Modular_Object
is new C393A03_0
.Counting_Object
with private;
112 -- inherits Initialize, Bump, Zero and Value,
113 -- inherits abstract Swap, Create and Clear
115 procedure Swap
( A
,B
: in out Modular_Object
);
116 procedure Clear
( It
: in out Modular_Object
);
117 procedure Set_Max
( It
: in out Modular_Object
; Value
: Natural );
118 function Create
return Modular_Object
;
122 type Modular_Object
is new C393A03_0
.Counting_Object
with
129 -----------------------------------------------------------------------------
132 package body C393A03_1
is
134 procedure Swap
( A
,B
: in out Modular_Object
) is
135 T
: constant Modular_Object
:= B
;
137 F393A00_0
.TC_Touch
('1');
142 procedure Clear
( It
: in out Modular_Object
) is
144 F393A00_0
.TC_Touch
('2');
148 procedure Set_Max
( It
: in out Modular_Object
; Value
: Natural ) is
150 F393A00_0
.TC_Touch
('3');
151 It
.Max_Value
:= Value
;
154 function Create
return Modular_Object
is
155 AMO
: Modular_Object
;
157 F393A00_0
.TC_Touch
('4');
158 AMO
.Max_Value
:= Natural'Last;
164 --------------------------------------------------------------------- C393A03
173 A_Thing
: C393A03_1
.Modular_Object
;
174 Another_Thing
: C393A03_1
.Modular_Object
;
176 procedure Initialize
( It
: in out C393A03_0
.Counting_Object
'Class ) is
178 C393A03_0
.Initialize
( It
); -- dispatch to inherited procedure
181 procedure Bump
( It
: in out C393A03_0
.Counting_Object
'Class ) is
183 C393A03_0
.Bump
( It
); -- dispatch to non-abstract procedure
186 procedure Set_Max
( It
: in out C393A03_1
.Modular_Object
'Class;
189 C393A03_1
.Set_Max
( It
, Val
); -- dispatch to non-abstract procedure
192 procedure Swap
( A
, B
: in out C393A03_0
.Counting_Object
'Class ) is
194 C393A03_0
.Swap
( A
, B
); -- dispatch to inherited abstract procedure
197 procedure Zero
( It
: in out C393A03_0
.Counting_Object
'Class ) is
199 C393A03_0
.Zero
( It
); -- dispatch to non-abstract procedure
202 begin -- Main test procedure.
204 Report
.Test
("C393A03", "Check that a non-abstract primitive subprogram "
205 & "of an abstract type can be called as a "
206 & "dispatching operation and that the body of this "
207 & "subprogram can make a dispatching call to an "
208 & "abstract operation of the corresponding "
211 A_Thing
:= C393A03_1
.Create
; -- Max_Value = Natural'Last
212 F393A00_0
.TC_Validate
( "4", "Overridden primitive layer 2");
214 Initialize
( A_Thing
);
215 Initialize
( Another_Thing
);
216 F393A00_0
.TC_Validate
( "aa", "Non-abstract primitive layer 0");
218 Bump
( A_Thing
); -- Tally = 1
219 F393A00_0
.TC_Validate
( "A", "Non-abstract primitive layer 1");
221 Set_Max
( A_Thing
, 42 ); -- Max_Value = 42
222 F393A00_0
.TC_Validate
( "3", "Non-abstract normal layer 2");
224 if not F393A00_1
.Initialized
( A_Thing
) then
225 Report
.Failed
("Initialize didn't");
227 F393A00_0
.TC_Validate
( "b", "Class-wide layer 0");
229 Swap
( A_Thing
, Another_Thing
);
230 F393A00_0
.TC_Validate
( "1", "Overridden abstract layer 2");
233 F393A00_0
.TC_Validate
( "B2", "Non-abstract layer 0, calls dispatch");
235 if C393A03_0
.Value
( A_Thing
) /= 0 then
236 Report
.Failed
("Zero didn't");
238 F393A00_0
.TC_Validate
( "C", "Class-wide normal layer 2");