annotate gcc/testsuite/ada/acats/tests/cxa/cxacc01.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CXACC01.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that the use of 'Class'Output and 'Class'Input allow stream
kono
parents:
diff changeset
28 -- manipulation of objects of non-limited class-wide types.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- TEST DESCRIPTION:
kono
parents:
diff changeset
31 -- This test demonstrates the uses of 'Class'Output and 'Class'Input
kono
parents:
diff changeset
32 -- in moving objects of a particular class to and from a stream file.
kono
parents:
diff changeset
33 -- A procedure uses a class-wide parameter to move objects of specific
kono
parents:
diff changeset
34 -- types in the class to the stream, using the 'Class'Output attribute
kono
parents:
diff changeset
35 -- of the root type of the class. A function returns a class-wide object,
kono
parents:
diff changeset
36 -- using the 'Class'Input attribute of the root type of the class to
kono
parents:
diff changeset
37 -- extract the object from the stream.
kono
parents:
diff changeset
38 -- A field-by-field comparison of record objects is performed to validate
kono
parents:
diff changeset
39 -- the data read from the stream. Operator precedence rules are used
kono
parents:
diff changeset
40 -- in the comparison rather than parentheses.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
43 -- This test is applicable to all implementations capable of supporting
kono
parents:
diff changeset
44 -- external Stream_IO files.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 -- CHANGE HISTORY:
kono
parents:
diff changeset
48 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
49 -- 14 Nov 95 SAIC Corrected prefix of 'Tag attribute for ACVC 2.0.1.
kono
parents:
diff changeset
50 -- 24 Aug 96 SAIC Changed a call to "Create" to "Reset".
kono
parents:
diff changeset
51 -- 26 Feb 97 CTA.PWB Allowed for non-support of some IO operations.
kono
parents:
diff changeset
52 --!
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 with FXACC00, Ada.Streams.Stream_IO, Ada.Tags, Report;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 procedure CXACC01 is
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 Order_File : Ada.Streams.Stream_IO.File_Type;
kono
parents:
diff changeset
59 Order_Stream : Ada.Streams.Stream_IO.Stream_Access;
kono
parents:
diff changeset
60 Order_Filename : constant String :=
kono
parents:
diff changeset
61 Report.Legal_File_Name ( Nam => "CXACC01" );
kono
parents:
diff changeset
62 Incomplete : exception;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 begin
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Report.Test ("CXACC01", "Check that the use of 'Class'Output " &
kono
parents:
diff changeset
67 "and 'Class'Input allow stream manipulation " &
kono
parents:
diff changeset
68 "of objects of non-limited class-wide types");
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 Test_for_Stream_IO_Support:
kono
parents:
diff changeset
71 begin
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 -- If an implementation does not support Stream_IO in a particular
kono
parents:
diff changeset
74 -- environment, the exception Use_Error or Name_Error will be raised on
kono
parents:
diff changeset
75 -- calls to various Stream_IO operations. This block statement
kono
parents:
diff changeset
76 -- encloses a call to Create, which should produce an exception in a
kono
parents:
diff changeset
77 -- non-supportive environment. These exceptions will be handled to
kono
parents:
diff changeset
78 -- produce a Not_Applicable result.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 Ada.Streams.Stream_IO.Create (Order_File,
kono
parents:
diff changeset
81 Ada.Streams.Stream_IO.Out_File,
kono
parents:
diff changeset
82 Order_Filename);
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 exception
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 when Ada.Streams.Stream_IO.Use_Error | Ada.Streams.Stream_IO.Name_Error =>
kono
parents:
diff changeset
87 Report.Not_Applicable
kono
parents:
diff changeset
88 ( "Files not supported - Create as Out_File for Stream_IO" );
kono
parents:
diff changeset
89 raise Incomplete;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 end Test_for_Stream_IO_Support;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 Operational_Test_Block:
kono
parents:
diff changeset
94 declare
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- Store tag values associated with objects of tagged types.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 TC_Box_Office_Tag : constant String :=
kono
parents:
diff changeset
99 Ada.Tags.External_Tag(FXACC00.Ticket_Request'Tag);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 TC_Summer_Tag : constant String :=
kono
parents:
diff changeset
102 Ada.Tags.External_Tag(FXACC00.Subscriber_Request'Tag);
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 TC_Mayoral_Tag : constant String :=
kono
parents:
diff changeset
105 Ada.Tags.External_Tag(FXACC00.VIP_Request'Tag);
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 TC_Late_Tag : constant String :=
kono
parents:
diff changeset
108 Ada.Tags.External_Tag(FXACC00.Last_Minute_Request'Tag);
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 -- The following procedure will take an object of the Ticket_Request
kono
parents:
diff changeset
111 -- class and output it to the stream. Objects of any extended type
kono
parents:
diff changeset
112 -- in the class can be output to the stream with this procedure.
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 procedure Order_Entry (Order : FXACC00.Ticket_Request'Class) is
kono
parents:
diff changeset
115 begin
kono
parents:
diff changeset
116 FXACC00.Ticket_Request'Class'Output (Order_Stream, Order);
kono
parents:
diff changeset
117 end Order_Entry;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- The following function will retrieve from the stream an object of
kono
parents:
diff changeset
121 -- the Ticket_Request class.
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 function Order_Retrieval return FXACC00.Ticket_Request'Class is
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125 return FXACC00.Ticket_Request'Class'Input (Order_Stream);
kono
parents:
diff changeset
126 end Order_Retrieval;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 begin
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 Order_Stream := Ada.Streams.Stream_IO.Stream (Order_File);
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 -- Store the data objects in the stream.
kono
parents:
diff changeset
133 -- Each of the objects is of a different type within the class.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 Order_Entry (FXACC00.Box_Office_Request); -- Object of root type
kono
parents:
diff changeset
136 Order_Entry (FXACC00.Summer_Subscription); -- Obj. of extended type
kono
parents:
diff changeset
137 Order_Entry (FXACC00.Mayoral_Ticket_Request); -- Obj. of extended type
kono
parents:
diff changeset
138 Order_Entry (FXACC00.Late_Request); -- Object of twice
kono
parents:
diff changeset
139 -- extended type.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 -- Reset mode of stream to In_File prior to reading data from it.
kono
parents:
diff changeset
142 Reset1:
kono
parents:
diff changeset
143 begin
kono
parents:
diff changeset
144 Ada.Streams.Stream_IO.Reset (Order_File,
kono
parents:
diff changeset
145 Ada.Streams.Stream_IO.In_File);
kono
parents:
diff changeset
146 exception
kono
parents:
diff changeset
147 when Ada.Streams.Stream_IO.Use_Error =>
kono
parents:
diff changeset
148 Report.Not_Applicable
kono
parents:
diff changeset
149 ( "Reset to In_File not supported for Stream_IO - 1" );
kono
parents:
diff changeset
150 raise Incomplete;
kono
parents:
diff changeset
151 end Reset1;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 Process_Order_Block:
kono
parents:
diff changeset
154 declare
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 use FXACC00;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 -- Declare variables of the root type class,
kono
parents:
diff changeset
159 -- and initialize them with class-wide objects returned from
kono
parents:
diff changeset
160 -- the stream as function result.
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Order_1 : Ticket_Request'Class := Order_Retrieval;
kono
parents:
diff changeset
163 Order_2 : Ticket_Request'Class := Order_Retrieval;
kono
parents:
diff changeset
164 Order_3 : Ticket_Request'Class := Order_Retrieval;
kono
parents:
diff changeset
165 Order_4 : Ticket_Request'Class := Order_Retrieval;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 -- Declare objects of the specific types from within the class
kono
parents:
diff changeset
168 -- that correspond to the types of the data written to the
kono
parents:
diff changeset
169 -- stream. Perform a type conversion on the class-wide objects.
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 Ticket_Order : Ticket_Request :=
kono
parents:
diff changeset
172 Ticket_Request(Order_1);
kono
parents:
diff changeset
173 Subscriber_Order : Subscriber_Request :=
kono
parents:
diff changeset
174 Subscriber_Request(Order_2);
kono
parents:
diff changeset
175 VIP_Order : VIP_Request :=
kono
parents:
diff changeset
176 VIP_Request(Order_3);
kono
parents:
diff changeset
177 Last_Minute_Order : Last_Minute_Request :=
kono
parents:
diff changeset
178 Last_Minute_Request(Order_4);
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 begin
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 -- Perform a field-by-field comparison of all the class-wide
kono
parents:
diff changeset
183 -- objects input from the stream with specific type objects
kono
parents:
diff changeset
184 -- originally written to the stream.
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 if Ticket_Order.Location /=
kono
parents:
diff changeset
187 Box_Office_Request.Location or
kono
parents:
diff changeset
188 Ticket_Order.Number_Of_Tickets /=
kono
parents:
diff changeset
189 Box_Office_Request.Number_Of_Tickets
kono
parents:
diff changeset
190 then
kono
parents:
diff changeset
191 Report.Failed ("Ticket_Request object validation failure");
kono
parents:
diff changeset
192 end if;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 if Subscriber_Order.Location /=
kono
parents:
diff changeset
195 Summer_Subscription.Location or
kono
parents:
diff changeset
196 Subscriber_Order.Number_Of_Tickets /=
kono
parents:
diff changeset
197 Summer_Subscription.Number_Of_Tickets or
kono
parents:
diff changeset
198 Subscriber_Order.Subscription_Number /=
kono
parents:
diff changeset
199 Summer_Subscription.Subscription_Number
kono
parents:
diff changeset
200 then
kono
parents:
diff changeset
201 Report.Failed ("Subscriber_Request object validation failure");
kono
parents:
diff changeset
202 end if;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 if VIP_Order.Location /=
kono
parents:
diff changeset
205 Mayoral_Ticket_Request.Location or
kono
parents:
diff changeset
206 VIP_Order.Number_Of_Tickets /=
kono
parents:
diff changeset
207 Mayoral_Ticket_Request.Number_Of_Tickets or
kono
parents:
diff changeset
208 VIP_Order.Rank /=
kono
parents:
diff changeset
209 Mayoral_Ticket_Request.Rank
kono
parents:
diff changeset
210 then
kono
parents:
diff changeset
211 Report.Failed ("VIP_Request object validation failure");
kono
parents:
diff changeset
212 end if;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 if Last_Minute_Order.Location /=
kono
parents:
diff changeset
215 Late_Request.Location or
kono
parents:
diff changeset
216 Last_Minute_Order.Number_Of_Tickets /=
kono
parents:
diff changeset
217 Late_Request.Number_Of_Tickets or
kono
parents:
diff changeset
218 Last_Minute_Order.Rank /=
kono
parents:
diff changeset
219 Late_Request.Rank or
kono
parents:
diff changeset
220 Last_Minute_Order.Special_Consideration /=
kono
parents:
diff changeset
221 Late_Request.Special_Consideration or
kono
parents:
diff changeset
222 Last_Minute_Order.Donation /=
kono
parents:
diff changeset
223 Late_Request.Donation
kono
parents:
diff changeset
224 then
kono
parents:
diff changeset
225 Report.Failed ("Last_Minute_Request object validation failure");
kono
parents:
diff changeset
226 end if;
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 -- Verify tag values from before and after processing.
kono
parents:
diff changeset
229 -- The 'Tag attribute is used with objects of a class-wide type.
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 if TC_Box_Office_Tag /=
kono
parents:
diff changeset
232 Ada.Tags.External_Tag(Order_1'Tag)
kono
parents:
diff changeset
233 then
kono
parents:
diff changeset
234 Report.Failed("Failed tag comparison - 1");
kono
parents:
diff changeset
235 end if;
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 if TC_Summer_Tag /=
kono
parents:
diff changeset
238 Ada.Tags.External_Tag(Order_2'Tag)
kono
parents:
diff changeset
239 then
kono
parents:
diff changeset
240 Report.Failed("Failed tag comparison - 2");
kono
parents:
diff changeset
241 end if;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 if TC_Mayoral_Tag /=
kono
parents:
diff changeset
244 Ada.Tags.External_Tag(Order_3'Tag)
kono
parents:
diff changeset
245 then
kono
parents:
diff changeset
246 Report.Failed("Failed tag comparison - 3");
kono
parents:
diff changeset
247 end if;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 if TC_Late_Tag /=
kono
parents:
diff changeset
250 Ada.Tags.External_Tag(Order_4'Tag)
kono
parents:
diff changeset
251 then
kono
parents:
diff changeset
252 Report.Failed("Failed tag comparison - 4");
kono
parents:
diff changeset
253 end if;
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 end Process_Order_Block;
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 -- After all the data has been correctly extracted, the file
kono
parents:
diff changeset
258 -- should be empty.
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 if not Ada.Streams.Stream_IO.End_Of_File (Order_File) then
kono
parents:
diff changeset
261 Report.Failed ("Stream file not empty");
kono
parents:
diff changeset
262 end if;
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 exception
kono
parents:
diff changeset
265 when Incomplete =>
kono
parents:
diff changeset
266 raise;
kono
parents:
diff changeset
267 when Constraint_Error =>
kono
parents:
diff changeset
268 Report.Failed ("Constraint_Error raised in Operational Block");
kono
parents:
diff changeset
269 when others =>
kono
parents:
diff changeset
270 Report.Failed ("Exception raised in Operational Test Block");
kono
parents:
diff changeset
271 end Operational_Test_Block;
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 Deletion:
kono
parents:
diff changeset
274 begin
kono
parents:
diff changeset
275 if Ada.Streams.Stream_IO.Is_Open (Order_File) then
kono
parents:
diff changeset
276 Ada.Streams.Stream_IO.Delete (Order_File);
kono
parents:
diff changeset
277 else
kono
parents:
diff changeset
278 Ada.Streams.Stream_IO.Open (Order_File,
kono
parents:
diff changeset
279 Ada.Streams.Stream_IO.Out_File,
kono
parents:
diff changeset
280 Order_Filename);
kono
parents:
diff changeset
281 Ada.Streams.Stream_IO.Delete (Order_File);
kono
parents:
diff changeset
282 end if;
kono
parents:
diff changeset
283 exception
kono
parents:
diff changeset
284 when others =>
kono
parents:
diff changeset
285 Report.Failed
kono
parents:
diff changeset
286 ( "Delete not properly implemented for Stream_IO" );
kono
parents:
diff changeset
287 end Deletion;
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 Report.Result;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 exception
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 when Incomplete =>
kono
parents:
diff changeset
294 Report.Result;
kono
parents:
diff changeset
295 when others =>
kono
parents:
diff changeset
296 Report.Failed ( "Unexpected exception" );
kono
parents:
diff changeset
297 Report.Result;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 end CXACC01;