annotate gcc/testsuite/ada/acats/tests/cxa/cxaa011.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 -- CXAA011.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 operations of Text_IO.Enumeration_IO perform correctly
kono
parents:
diff changeset
28 -- on files of Append_File mode, for instantiations using
kono
parents:
diff changeset
29 -- enumeration types. Check that Enumeration_IO procedures Put and Get
kono
parents:
diff changeset
30 -- properly transfer enumeration data to/from data files.
kono
parents:
diff changeset
31 -- Check that the formatting parameters available in the package can
kono
parents:
diff changeset
32 -- be used and modified successfully in the storage and retrieval of data.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- TEST DESCRIPTION:
kono
parents:
diff changeset
35 -- This test is designed to simulate an environment where a data file
kono
parents:
diff changeset
36 -- that holds enumeration type information is reset from it current mode
kono
parents:
diff changeset
37 -- to allow the appending of data to the end of the This process
kono
parents:
diff changeset
38 -- of Reset/Write can be repeated as necessary. All data written
kono
parents:
diff changeset
39 -- to the file is verified for accuracy when retrieved from the file.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- This test verifies issues of resetting a file created in Out_File mode
kono
parents:
diff changeset
42 -- to Append_File mode, resetting from Append_File mode to In_File mode,
kono
parents:
diff changeset
43 -- as well as a variety of Text_IO and Enumeration_IO predefined
kono
parents:
diff changeset
44 -- subprograms.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
47 -- This test is applicable only to implementations that support text
kono
parents:
diff changeset
48 -- files.
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 --
kono
parents:
diff changeset
51 -- CHANGE HISTORY:
kono
parents:
diff changeset
52 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
53 -- 25 Feb 97 PWB.CTA Allowed for non-support of some IO operations
kono
parents:
diff changeset
54 --!
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 with Ada.Text_IO;
kono
parents:
diff changeset
57 with Report;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 procedure CXAA011 is
kono
parents:
diff changeset
60 use Ada;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 Status_Log : Text_IO.File_Type;
kono
parents:
diff changeset
63 Status_Log_Filename : constant String :=
kono
parents:
diff changeset
64 Report.Legal_File_Name ( Nam => "CXAA011" );
kono
parents:
diff changeset
65 Incomplete : exception;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 begin
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 Report.Test ("CXAA011", "Check that the operations of " &
kono
parents:
diff changeset
70 "Text_IO.Enumeration_IO operate correctly for " &
kono
parents:
diff changeset
71 "files with mode Append_File");
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Test_for_Text_IO_Support:
kono
parents:
diff changeset
74 begin
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 -- An implementation that does not support Text_IO in a particular
kono
parents:
diff changeset
77 -- environment will raise Use_Error on calls to various
kono
parents:
diff changeset
78 -- Text_IO operations. This block statement encloses a call to
kono
parents:
diff changeset
79 -- Create, which should raise the exception in a non-supportive
kono
parents:
diff changeset
80 -- environment. This exception will be handled to produce a
kono
parents:
diff changeset
81 -- Not_Applicable result.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 Text_IO.Create (File => Status_Log,
kono
parents:
diff changeset
84 Mode => Text_IO.Out_File,
kono
parents:
diff changeset
85 Name => Status_Log_Filename);
kono
parents:
diff changeset
86 exception
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 when Text_IO.Use_Error | Text_IO.Name_Error =>
kono
parents:
diff changeset
89 Report.Not_Applicable
kono
parents:
diff changeset
90 ( "Files not supported - Create as Out_File for Text_IO" );
kono
parents:
diff changeset
91 raise Incomplete;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 end Test_for_Text_IO_Support;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 Operational_Test_Block:
kono
parents:
diff changeset
97 declare
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 type Days_In_Week is (Monday, Tuesday, Wednesday, Thursday, Friday,
kono
parents:
diff changeset
100 Saturday, Sunday);
kono
parents:
diff changeset
101 type Hours_In_Day is (A0000, A0600, P1200, P0600); -- Six hour
kono
parents:
diff changeset
102 -- blocks.
kono
parents:
diff changeset
103 type Status_Type is (Operational, Off_Line);
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 type Status_Record_Type is record
kono
parents:
diff changeset
106 Day : Days_In_Week;
kono
parents:
diff changeset
107 Hour : Hours_In_Day;
kono
parents:
diff changeset
108 Status : Status_Type;
kono
parents:
diff changeset
109 end record;
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 Morning_Reading : Status_Record_Type :=
kono
parents:
diff changeset
112 (Wednesday, A0600, Operational);
kono
parents:
diff changeset
113 Evening_Reading : Status_Record_Type :=
kono
parents:
diff changeset
114 (Saturday, P0600, Off_Line);
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 package Day_IO is new Text_IO.Enumeration_IO (Days_In_Week);
kono
parents:
diff changeset
117 package Hours_IO is new Text_IO.Enumeration_IO (Hours_In_Day);
kono
parents:
diff changeset
118 package Status_IO is new Text_IO.Enumeration_IO (Status_Type);
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 -- The following function simulates the hourly recording of equipment
kono
parents:
diff changeset
122 -- status.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 function Record_Status (Reading : Status_Record_Type)
kono
parents:
diff changeset
125 return Boolean is
kono
parents:
diff changeset
126 use Text_IO; -- To provide visibility to type Type_Set and
kono
parents:
diff changeset
127 -- enumeration literal Upper_Case.
kono
parents:
diff changeset
128 begin
kono
parents:
diff changeset
129 Day_IO.Put (File => Status_Log,
kono
parents:
diff changeset
130 Item => Reading.Day,
kono
parents:
diff changeset
131 Set => Type_Set'(Upper_Case));
kono
parents:
diff changeset
132 Hours_IO.Put (Status_Log, Reading.Hour, 7);
kono
parents:
diff changeset
133 Status_IO.Put (Status_Log, Reading.Status,
kono
parents:
diff changeset
134 Width => 8, Set => Lower_Case);
kono
parents:
diff changeset
135 Text_IO.New_Line (Status_Log);
kono
parents:
diff changeset
136 return (True);
kono
parents:
diff changeset
137 exception
kono
parents:
diff changeset
138 when others => return False;
kono
parents:
diff changeset
139 end Record_Status;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 begin
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 -- The usage scenario intended is as follows:
kono
parents:
diff changeset
144 -- File is created.
kono
parents:
diff changeset
145 -- Unrelated/unknown file processing occurs.
kono
parents:
diff changeset
146 -- On six hour intervals, file is reset to Append_File mode.
kono
parents:
diff changeset
147 -- Data is appended to file.
kono
parents:
diff changeset
148 -- Unrelated/unknown file processing resumes.
kono
parents:
diff changeset
149 -- Reset/Append process is repeated.
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 Reset1:
kono
parents:
diff changeset
152 begin
kono
parents:
diff changeset
153 Text_IO.Reset (Status_Log, -- Reset to
kono
parents:
diff changeset
154 Text_IO.Append_File); -- Append mode.
kono
parents:
diff changeset
155 exception
kono
parents:
diff changeset
156 when Text_IO.Use_Error =>
kono
parents:
diff changeset
157 Report.Not_Applicable
kono
parents:
diff changeset
158 ( "Reset to Append_File not supported for Text_IO" );
kono
parents:
diff changeset
159 raise Incomplete;
kono
parents:
diff changeset
160 end Reset1;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Day_IO.Default_Width := Days_In_Week'Width + 5; -- Default values
kono
parents:
diff changeset
163 -- are modifiable.
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 if not Record_Status (Morning_Reading) then -- Enter data.
kono
parents:
diff changeset
166 Report.Failed ("Exception occurred during data file update");
kono
parents:
diff changeset
167 end if;
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 Reset2:
kono
parents:
diff changeset
170 begin
kono
parents:
diff changeset
171 Text_IO.Reset (Status_Log, -- Reset to
kono
parents:
diff changeset
172 Text_IO.Append_File); -- Append mode.
kono
parents:
diff changeset
173 exception
kono
parents:
diff changeset
174 when Text_IO.Use_Error =>
kono
parents:
diff changeset
175 Report.Not_Applicable
kono
parents:
diff changeset
176 ( "Reset to Append_File not supported for Text_IO" );
kono
parents:
diff changeset
177 raise Incomplete;
kono
parents:
diff changeset
178 end Reset2;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 if not Record_Status (Evening_Reading) then -- Enter data.
kono
parents:
diff changeset
181 Report.Failed ("Exception occurred during data file update");
kono
parents:
diff changeset
182 end if;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 Test_Verification_Block:
kono
parents:
diff changeset
185 declare
kono
parents:
diff changeset
186 TC_Reading1 : Status_Record_Type;
kono
parents:
diff changeset
187 TC_Reading2 : Status_Record_Type;
kono
parents:
diff changeset
188 begin
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 Reset3:
kono
parents:
diff changeset
191 begin
kono
parents:
diff changeset
192 Text_IO.Reset (Status_Log, Text_IO.In_File); -- Reset for
kono
parents:
diff changeset
193 -- reading.
kono
parents:
diff changeset
194 exception
kono
parents:
diff changeset
195 when Text_IO.Use_Error =>
kono
parents:
diff changeset
196 Report.Not_Applicable
kono
parents:
diff changeset
197 ( "Reset to In_File not supported for Text_IO" );
kono
parents:
diff changeset
198 raise Incomplete;
kono
parents:
diff changeset
199 end Reset3;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 Day_IO.Get (Status_Log, TC_Reading1.Day); -- Read data from
kono
parents:
diff changeset
202 Hours_IO.Get (Status_Log, TC_Reading1.Hour); -- first record.
kono
parents:
diff changeset
203 Status_IO.Get (Status_Log, TC_Reading1.Status);
kono
parents:
diff changeset
204 Text_IO.Skip_Line (Status_Log);
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 -- Verify the data read from the file. Compare with the
kono
parents:
diff changeset
207 -- record that was originally entered into the file.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 if (TC_Reading1 /= Morning_Reading) then
kono
parents:
diff changeset
210 Report.Failed ("Data error on reading first record");
kono
parents:
diff changeset
211 end if;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 Day_IO.Get (Status_Log, TC_Reading2.Day); -- Read data from
kono
parents:
diff changeset
214 Hours_IO.Get (Status_Log, TC_Reading2.Hour); -- second record.
kono
parents:
diff changeset
215 Status_IO.Get (Status_Log, TC_Reading2.Status);
kono
parents:
diff changeset
216 Text_IO.Skip_Line (Status_Log);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 -- Verify all of the data fields read from the file. Compare
kono
parents:
diff changeset
219 -- with the values that were originally entered into the file.
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 if (TC_Reading2.Day /= Evening_Reading.Day) or
kono
parents:
diff changeset
222 (TC_Reading2.Hour /= Evening_Reading.Hour) or
kono
parents:
diff changeset
223 (TC_Reading2.Status /= Evening_Reading.Status) then
kono
parents:
diff changeset
224 Report.Failed ("Data error on reading second record");
kono
parents:
diff changeset
225 end if;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 exception
kono
parents:
diff changeset
228 when Incomplete =>
kono
parents:
diff changeset
229 raise;
kono
parents:
diff changeset
230 when others =>
kono
parents:
diff changeset
231 Report.Failed ("Error raised during data verification");
kono
parents:
diff changeset
232 end Test_Verification_Block;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 exception
kono
parents:
diff changeset
235 when Incomplete =>
kono
parents:
diff changeset
236 raise;
kono
parents:
diff changeset
237 when others =>
kono
parents:
diff changeset
238 Report.Failed ("Exception in Text_IO.Enumeration_IO processing");
kono
parents:
diff changeset
239 end Operational_Test_Block;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 Final_Block:
kono
parents:
diff changeset
242 begin
kono
parents:
diff changeset
243 -- Delete the external file.
kono
parents:
diff changeset
244 if Text_IO.Is_Open (Status_Log) then
kono
parents:
diff changeset
245 Text_IO.Delete (Status_Log);
kono
parents:
diff changeset
246 else
kono
parents:
diff changeset
247 Text_IO.Open (Status_Log, Text_IO.Out_File, Status_Log_Filename);
kono
parents:
diff changeset
248 Text_IO.Delete (Status_Log);
kono
parents:
diff changeset
249 end if;
kono
parents:
diff changeset
250 exception
kono
parents:
diff changeset
251 when Text_IO.Use_Error =>
kono
parents:
diff changeset
252 Report.Failed
kono
parents:
diff changeset
253 ( "Delete not properly implemented for Text_IO" );
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 end Final_Block;
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 Report.Result;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 exception
kono
parents:
diff changeset
260 when Incomplete =>
kono
parents:
diff changeset
261 Report.Result;
kono
parents:
diff changeset
262 when others =>
kono
parents:
diff changeset
263 Report.Failed ( "Unexpected exception" );
kono
parents:
diff changeset
264 Report.Result;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 end CXAA011;