3 -- Grant of Unlimited Rights
5 -- The Ada Conformity Assessment Authority (ACAA) holds unlimited
6 -- rights in the software and documentation contained herein. Unlimited
7 -- rights are the same as those granted by the U.S. Government for older
8 -- parts of the Ada Conformity Assessment Test Suite, and are defined
9 -- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
10 -- intends to confer upon all recipients unlimited rights equal to those
11 -- held by the ACAA. These rights include rights to use, duplicate,
12 -- release or disclose the released technical data and computer software
13 -- in whole or in part, in any manner and for any purpose whatsoever, and
14 -- to have or permit others to do so.
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 the Read, Write, Input, and Output attributes are inherited
28 -- for untagged derived types. (Defect Report 8652/0040,
29 -- as reflected in Technical Corrigendum 1, 13.13.2(8.1/1) and
33 -- 30 JUL 2001 PHL Initial version.
34 -- 5 DEC 2001 RLB Reformatted for ACATS.
45 type Int
is range 1 .. 10;
46 type Str
is array (Int
range <>) of Character;
48 procedure Read
(Stream
: access Root_Stream_Type
'Class;
50 procedure Write
(Stream
: access Root_Stream_Type
'Class; Item
: Int
'Base);
51 function Input
(Stream
: access Root_Stream_Type
'Class) return Int
'Base;
52 procedure Output
(Stream
: access Root_Stream_Type
'Class; Item
: Int
'Base);
54 for Int
'Read use Read
;
55 for Int
'Write use Write
;
56 for Int
'Input use Input
;
57 for Int
'Output use Output
;
60 type Parent
(D1
, D2
: Int
; B
: Boolean) is
71 procedure Read
(Stream
: access Root_Stream_Type
'Class; Item
: out Parent
);
72 procedure Write
(Stream
: access Root_Stream_Type
'Class; Item
: Parent
);
73 function Input
(Stream
: access Root_Stream_Type
'Class) return Parent
;
74 procedure Output
(Stream
: access Root_Stream_Type
'Class; Item
: Parent
);
76 for Parent
'Read use Read
;
77 for Parent
'Write use Write
;
78 for Parent
'Input use Input
;
79 for Parent
'Output use Output
;
83 (Stream
: access Root_Stream_Type
'Class; Item
: out Int
) is
85 Integer'Read (Stream
, Integer (Item
));
88 procedure Actual_Write
89 (Stream
: access Root_Stream_Type
'Class; Item
: Int
) is
91 Integer'Write (Stream
, Integer (Item
));
94 function Actual_Input
(Stream
: access Root_Stream_Type
'Class) return Int
is
96 return Int
(Integer'Input (Stream
));
99 procedure Actual_Output
100 (Stream
: access Root_Stream_Type
'Class; Item
: Int
) is
102 Integer'Output (Stream
, Integer (Item
));
106 procedure Actual_Read
107 (Stream
: access Root_Stream_Type
'Class; Item
: out Parent
) is
113 Float'Read (Stream
, Item
.C2
);
115 Str
'Read (Stream
, Item
.S
);
118 procedure Actual_Write
119 (Stream
: access Root_Stream_Type
'Class; Item
: Parent
) is
123 null; -- Don't write C1
125 Float'Write (Stream
, Item
.C2
);
127 Str
'Write (Stream
, Item
.S
);
130 function Actual_Input
131 (Stream
: access Root_Stream_Type
'Class) return Parent
is
135 Int
'Read (Stream
, D2
);
136 Boolean'Read (Stream
, B
);
137 Int
'Read (Stream
, D1
);
140 Item
: Parent
(D1
=> D1
, D2
=> D2
, B
=> B
);
142 Parent
'Read (Stream
, Item
);
148 procedure Actual_Output
149 (Stream
: access Root_Stream_Type
'Class; Item
: Parent
) is
151 Int
'Write (Stream
, Item
.D2
);
152 Boolean'Write (Stream
, Item
.B
);
153 Int
'Write (Stream
, Item
.D1
);
154 Parent
'Write (Stream
, Item
);
157 package Int_Ops
is new Counting_Stream_Ops
(T
=> Int
'Base,
158 Actual_Write
=> Actual_Write
,
159 Actual_Input
=> Actual_Input
,
160 Actual_Read
=> Actual_Read
,
161 Actual_Output
=> Actual_Output
);
163 package Parent_Ops
is
164 new Counting_Stream_Ops
(T
=> Parent
,
165 Actual_Write
=> Actual_Write
,
166 Actual_Input
=> Actual_Input
,
167 Actual_Read
=> Actual_Read
,
168 Actual_Output
=> Actual_Output
);
170 procedure Read
(Stream
: access Root_Stream_Type
'Class; Item
: out Int
'Base)
171 renames Int_Ops
.Read
;
172 procedure Write
(Stream
: access Root_Stream_Type
'Class; Item
: Int
'Base)
173 renames Int_Ops
.Write
;
174 function Input
(Stream
: access Root_Stream_Type
'Class) return Int
'Base
175 renames Int_Ops
.Input
;
176 procedure Output
(Stream
: access Root_Stream_Type
'Class; Item
: Int
'Base)
177 renames Int_Ops
.Output
;
179 procedure Read
(Stream
: access Root_Stream_Type
'Class; Item
: out Parent
)
180 renames Parent_Ops
.Read
;
181 procedure Write
(Stream
: access Root_Stream_Type
'Class; Item
: Parent
)
182 renames Parent_Ops
.Write
;
183 function Input
(Stream
: access Root_Stream_Type
'Class) return Parent
184 renames Parent_Ops
.Input
;
185 procedure Output
(Stream
: access Root_Stream_Type
'Class; Item
: Parent
)
186 renames Parent_Ops
.Output
;
189 Test
("CDD2A02", "Check that the Read, Write, Input, and Output " &
190 "attributes are inherited for untagged derived types");
194 type Derived1
is new Parent
;
195 S
: aliased My_Stream
(1000);
196 X1
: Derived1
(D1
=> Int
(Ident_Int
(2)),
197 D2
=> Int
(Ident_Int
(5)), B
=> Ident_Bool
(True));
198 Y1
: Derived1
:= (D1
=> 3,
201 S
=> Str
(Ident_Str
("3456")),
202 C1
=> Ident_Int
(100));
203 X2
: Derived1
(D1
=> Int
(Ident_Int
(2)),
204 D2
=> Int
(Ident_Int
(5)), B
=> Ident_Bool
(True));
206 X1
.S
:= Str
(Ident_Str
("bcde"));
207 X1
.C2
:= Float (Ident_Int
(4));
209 Derived1
'Write (S
'Access, X1
);
210 if Int_Ops
.Get_Counts
/=
211 (Read
=> 0, Write
=> 0, Input
=> 0, Output
=> 0) then
212 Failed
("Error writing discriminants - 1");
214 if Parent_Ops
.Get_Counts
/=
215 (Read
=> 0, Write
=> 1, Input
=> 0, Output
=> 0) then
216 Failed
("Didn't call inherited Write - 1");
219 Derived1
'Read (S
'Access, X2
);
220 if Int_Ops
.Get_Counts
/=
221 (Read
=> 0, Write
=> 0, Input
=> 0, Output
=> 0) then
222 Failed
("Error reading discriminants - 1");
224 if Parent_Ops
.Get_Counts
/=
225 (Read
=> 1, Write
=> 1, Input
=> 0, Output
=> 0) then
226 Failed
("Didn't call inherited Read - 1");
232 S
=> Str
(Ident_Str
("bcde")),
233 C2
=> Float (Ident_Int
(4))) then
235 ("Inherited Read and Write are not inverses of each other - 1");
238 Derived1
'Output (S
'Access, Y1
);
239 if Int_Ops
.Get_Counts
/=
240 (Read
=> 0, Write
=> 2, Input
=> 0, Output
=> 0) then
241 Failed
("Error writing discriminants - 2");
243 if Parent_Ops
.Get_Counts
/=
244 (Read
=> 1, Write
=> 2, Input
=> 0, Output
=> 1) then
245 Failed
("Didn't call inherited Output - 2");
249 Y2
: Derived1
:= Derived1
'Input (S
'Access);
251 if Int_Ops
.Get_Counts
/=
252 (Read
=> 2, Write
=> 2, Input
=> 0, Output
=> 0) then
253 Failed
("Error reading discriminants - 2");
255 if Parent_Ops
.Get_Counts
/=
256 (Read
=> 2, Write
=> 2, Input
=> 1, Output
=> 1) then
257 Failed
("Didn't call inherited Input - 2");
263 S
=> Str
(Ident_Str
("3456")),
264 C1
=> Ident_Int
(7)) then
266 ("Inherited Input and Output are not inverses of each other - 2");
273 type Derived2
(D
: Int
) is new Parent
(D1
=> D
,
276 S
: aliased My_Stream
(1000);
277 X1
: Derived2
(D
=> Int
(Ident_Int
(7)));
278 Y1
: Derived2
:= (D
=> 8,
279 S
=> Str
(Ident_Str
("8")),
280 C1
=> Ident_Int
(200));
281 X2
: Derived2
(D
=> Int
(Ident_Int
(7)));
283 X1
.S
:= Str
(Ident_Str
("g"));
284 X1
.C1
:= Ident_Int
(4);
286 Derived2
'Write (S
'Access, X1
);
287 if Int_Ops
.Get_Counts
/=
288 (Read
=> 2, Write
=> 2, Input
=> 0, Output
=> 0) then
289 Failed
("Error writing discriminants - 3");
291 if Parent_Ops
.Get_Counts
/=
292 (Read
=> 2, Write
=> 3, Input
=> 1, Output
=> 1) then
293 Failed
("Didn't call inherited Write - 3");
296 Derived2
'Read (S
'Access, X2
);
297 if Int_Ops
.Get_Counts
/=
298 (Read
=> 2, Write
=> 2, Input
=> 0, Output
=> 0) then
299 Failed
("Error reading discriminants - 3");
301 if Parent_Ops
.Get_Counts
/=
302 (Read
=> 3, Write
=> 3, Input
=> 1, Output
=> 1) then
303 Failed
("Didn't call inherited Read - 3");
307 S
=> Str
(Ident_Str
("g")),
308 C1
=> Ident_Int
(7)) then
310 ("Inherited Read and Write are not inverses of each other - 3");
313 Derived2
'Output (S
'Access, Y1
);
314 if Int_Ops
.Get_Counts
/=
315 (Read
=> 2, Write
=> 4, Input
=> 0, Output
=> 0) then
316 Failed
("Error writing discriminants - 4");
318 if Parent_Ops
.Get_Counts
/=
319 (Read
=> 3, Write
=> 4, Input
=> 1, Output
=> 2) then
320 Failed
("Didn't call inherited Output - 4");
324 Y2
: Derived2
:= Derived2
'Input (S
'Access);
326 if Int_Ops
.Get_Counts
/=
327 (Read
=> 4, Write
=> 4, Input
=> 0, Output
=> 0) then
328 Failed
("Error reading discriminants - 4");
330 if Parent_Ops
.Get_Counts
/=
331 (Read
=> 4, Write
=> 4, Input
=> 2, Output
=> 2) then
332 Failed
("Didn't call inherited Input - 4");
336 S
=> Str
(Ident_Str
("8")),
337 C1
=> Ident_Int
(7)) then
339 ("Inherited Input and Output are not inverses of each other - 4");