annotate gcc/testsuite/ada/acats/tests/cxa/cxaa016.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 -- CXAA016.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 type File_Access is available in Ada.Text_IO, and that
kono
parents:
diff changeset
28 -- objects of this type designate File_Type objects.
kono
parents:
diff changeset
29 -- Check that function Set_Error will set the current default error file.
kono
parents:
diff changeset
30 -- Check that versions of Ada.Text_IO functions Standard_Input,
kono
parents:
diff changeset
31 -- Standard_Output, Standard_Error return File_Access values designating
kono
parents:
diff changeset
32 -- the standard system input, output, and error files.
kono
parents:
diff changeset
33 -- Check that versions of Ada.Text_IO functions Current_Input,
kono
parents:
diff changeset
34 -- Current_Output, Current_Error return File_Access values designating
kono
parents:
diff changeset
35 -- the current system input, output, and error files.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- TEST DESCRIPTION:
kono
parents:
diff changeset
38 -- This test tests the use of File_Access objects in referring
kono
parents:
diff changeset
39 -- to File_Type objects, as well as several new functions that return
kono
parents:
diff changeset
40 -- File_Access objects as results.
kono
parents:
diff changeset
41 -- Four user-defined files are created. These files will be set to
kono
parents:
diff changeset
42 -- function as current system input, output, and error files.
kono
parents:
diff changeset
43 -- Data will be read from and written to these files during the
kono
parents:
diff changeset
44 -- time at which they function as the current system files.
kono
parents:
diff changeset
45 -- An array of File_Access objects will be defined. It will be
kono
parents:
diff changeset
46 -- initialized using functions that return File_Access objects
kono
parents:
diff changeset
47 -- referencing the Standard and Current Input, Output, and Error files.
kono
parents:
diff changeset
48 -- This "saves" the initial system environment, which will be modified
kono
parents:
diff changeset
49 -- to use the user-defined files as the current default Input, Output,
kono
parents:
diff changeset
50 -- and Error files. At the end of the test, the data in this array
kono
parents:
diff changeset
51 -- will be used to restore the initial system environment.
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
54 -- This test is applicable to implementations capable of supporting
kono
parents:
diff changeset
55 -- external Text_IO files.
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 --
kono
parents:
diff changeset
58 -- CHANGE HISTORY:
kono
parents:
diff changeset
59 -- 25 May 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
60 -- 22 Apr 96 SAIC Incorporated reviewer comments for ACVC 2.1.
kono
parents:
diff changeset
61 -- 26 Feb 97 PWB.CTA Allowed for non-support of some IO operations.
kono
parents:
diff changeset
62 -- 18 Jan 99 RLB Repaired to allow Not_Applicable systems to
kono
parents:
diff changeset
63 -- fail delete.
kono
parents:
diff changeset
64 --!
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 with Ada.Text_IO;
kono
parents:
diff changeset
67 package CXAA016_0 is
kono
parents:
diff changeset
68 New_Input_File,
kono
parents:
diff changeset
69 New_Output_File,
kono
parents:
diff changeset
70 New_Error_File_1,
kono
parents:
diff changeset
71 New_Error_File_2 : aliased Ada.Text_IO.File_Type;
kono
parents:
diff changeset
72 end CXAA016_0;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 with Report;
kono
parents:
diff changeset
76 with Ada.Exceptions;
kono
parents:
diff changeset
77 with Ada.Text_IO; use Ada.Text_IO;
kono
parents:
diff changeset
78 with CXAA016_0; use CXAA016_0;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure CXAA016 is
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 Non_Applicable_System : exception;
kono
parents:
diff changeset
83 No_Reset : exception;
kono
parents:
diff changeset
84 Not_Applicable_System : Boolean := False;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Delete_File ( A_File : in out Ada.Text_IO.File_Type;
kono
parents:
diff changeset
87 ID_Num : in Integer ) is
kono
parents:
diff changeset
88 begin
kono
parents:
diff changeset
89 if not Ada.Text_IO.Is_Open ( A_File ) then
kono
parents:
diff changeset
90 Ada.Text_IO.Open ( A_File,
kono
parents:
diff changeset
91 Ada.Text_IO.In_File,
kono
parents:
diff changeset
92 Report.Legal_File_Name ( ID_Num ) );
kono
parents:
diff changeset
93 end if;
kono
parents:
diff changeset
94 Ada.Text_IO.Delete ( A_File );
kono
parents:
diff changeset
95 exception
kono
parents:
diff changeset
96 when Ada.Text_IO.Name_Error =>
kono
parents:
diff changeset
97 if Not_Applicable_System then
kono
parents:
diff changeset
98 null; -- File probably wasn't created.
kono
parents:
diff changeset
99 else
kono
parents:
diff changeset
100 Report.Failed ( "Can't open file for Text_IO" );
kono
parents:
diff changeset
101 end if;
kono
parents:
diff changeset
102 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
103 if Not_Applicable_System then
kono
parents:
diff changeset
104 null; -- File probably wasn't created.
kono
parents:
diff changeset
105 else
kono
parents:
diff changeset
106 Report.Failed ( "Delete not properly implemented for Text_IO" );
kono
parents:
diff changeset
107 end if;
kono
parents:
diff changeset
108 when others =>
kono
parents:
diff changeset
109 Report.Failed ( "Unexpected exception in Delete_File" );
kono
parents:
diff changeset
110 end Delete_File;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 begin
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 Report.Test ("CXAA016", "Check that the type File_Access is available " &
kono
parents:
diff changeset
115 "in Ada.Text_IO, and that objects of this " &
kono
parents:
diff changeset
116 "type designate File_Type objects");
kono
parents:
diff changeset
117 Test_Block:
kono
parents:
diff changeset
118 declare
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 use Ada.Exceptions;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 type System_File_Array_Type is
kono
parents:
diff changeset
123 array (Integer range <>) of File_Access;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 -- Fill the following array with the File_Access results of six
kono
parents:
diff changeset
126 -- functions.
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 Initial_Environment : System_File_Array_Type(1..6) :=
kono
parents:
diff changeset
129 ( Standard_Input,
kono
parents:
diff changeset
130 Standard_Output,
kono
parents:
diff changeset
131 Standard_Error,
kono
parents:
diff changeset
132 Current_Input,
kono
parents:
diff changeset
133 Current_Output,
kono
parents:
diff changeset
134 Current_Error );
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 New_Input_Ptr : File_Access := New_Input_File'Access;
kono
parents:
diff changeset
137 New_Output_Ptr : File_Access := New_Output_File'Access;
kono
parents:
diff changeset
138 New_Error_Ptr : File_Access := New_Error_File_1'Access;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 Line : String(1..80);
kono
parents:
diff changeset
141 Length : Natural := 0;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 Line_1 : constant String := "This is the first line in the Output file";
kono
parents:
diff changeset
144 Line_2 : constant String := "This is the next line in the Output file";
kono
parents:
diff changeset
145 Line_3 : constant String := "This is the first line in Error file 1";
kono
parents:
diff changeset
146 Line_4 : constant String := "This is the next line in Error file 1";
kono
parents:
diff changeset
147 Line_5 : constant String := "This is the first line in Error file 2";
kono
parents:
diff changeset
148 Line_6 : constant String := "This is the next line in Error file 2";
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 procedure New_File (The_File : in out File_Type;
kono
parents:
diff changeset
153 Mode : in File_Mode;
kono
parents:
diff changeset
154 Next : in Integer) is
kono
parents:
diff changeset
155 begin
kono
parents:
diff changeset
156 Create (The_File, Mode, Report.Legal_File_Name(Next));
kono
parents:
diff changeset
157 exception
kono
parents:
diff changeset
158 -- The following two exceptions may be raised if a system is not
kono
parents:
diff changeset
159 -- capable of supporting external Text_IO files. The handler will
kono
parents:
diff changeset
160 -- raise a user-defined exception which will result in a
kono
parents:
diff changeset
161 -- Not_Applicable result for the test.
kono
parents:
diff changeset
162 when Use_Error | Name_Error => raise Non_Applicable_System;
kono
parents:
diff changeset
163 end New_File;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 procedure Check_Initial_Environment (Env : System_File_Array_Type) is
kono
parents:
diff changeset
168 begin
kono
parents:
diff changeset
169 -- Check that the system has defined the following sources/
kono
parents:
diff changeset
170 -- destinations for input/output/error, and that the six functions
kono
parents:
diff changeset
171 -- returning File_Access values are available.
kono
parents:
diff changeset
172 if not (Env(1) = Standard_Input and
kono
parents:
diff changeset
173 Env(2) = Standard_Output and
kono
parents:
diff changeset
174 Env(3) = Standard_Error and
kono
parents:
diff changeset
175 Env(4) = Current_Input and
kono
parents:
diff changeset
176 Env(5) = Current_Output and
kono
parents:
diff changeset
177 Env(6) = Current_Error)
kono
parents:
diff changeset
178 then
kono
parents:
diff changeset
179 Report.Failed("At the start of the test, the Standard and " &
kono
parents:
diff changeset
180 "Current File_Access values associated with " &
kono
parents:
diff changeset
181 "system Input, Output, and Error files do " &
kono
parents:
diff changeset
182 "not correspond");
kono
parents:
diff changeset
183 end if;
kono
parents:
diff changeset
184 end Check_Initial_Environment;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 procedure Load_Input_File (Input_Ptr : in File_Access) is
kono
parents:
diff changeset
189 begin
kono
parents:
diff changeset
190 -- Load data into the file that will function as the user-defined
kono
parents:
diff changeset
191 -- system input file.
kono
parents:
diff changeset
192 Put_Line(Input_Ptr.all, Line_1);
kono
parents:
diff changeset
193 Put_Line(Input_Ptr.all, Line_2);
kono
parents:
diff changeset
194 Put_Line(Input_Ptr.all, Line_3);
kono
parents:
diff changeset
195 Put_Line(Input_Ptr.all, Line_4);
kono
parents:
diff changeset
196 Put_Line(Input_Ptr.all, Line_5);
kono
parents:
diff changeset
197 Put_Line(Input_Ptr.all, Line_6);
kono
parents:
diff changeset
198 end Load_Input_File;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 procedure Restore_Initial_Environment
kono
parents:
diff changeset
203 (Initial_Env : System_File_Array_Type) is
kono
parents:
diff changeset
204 begin
kono
parents:
diff changeset
205 -- Restore the Current Input, Output, and Error files to their
kono
parents:
diff changeset
206 -- original states.
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 Set_Input (Initial_Env(4).all);
kono
parents:
diff changeset
209 Set_Output(Initial_Env(5).all);
kono
parents:
diff changeset
210 Set_Error (Initial_Env(6).all);
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 -- At this point, the user-defined files that were functioning as
kono
parents:
diff changeset
213 -- the Current Input, Output, and Error files have been replaced in
kono
parents:
diff changeset
214 -- that capacity by the state of the original environment.
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 declare
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 -- Capture the state of the current environment.
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 Current_Env : System_File_Array_Type (1..6) :=
kono
parents:
diff changeset
221 (Standard_Input, Standard_Output, Standard_Error,
kono
parents:
diff changeset
222 Current_Input, Current_Output, Current_Error);
kono
parents:
diff changeset
223 begin
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 -- Compare the current environment with that of the saved
kono
parents:
diff changeset
226 -- initial environment.
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 if Current_Env /= Initial_Env then
kono
parents:
diff changeset
229 Report.Failed("Restored file environment was not the same " &
kono
parents:
diff changeset
230 "as the initial file environment");
kono
parents:
diff changeset
231 end if;
kono
parents:
diff changeset
232 end;
kono
parents:
diff changeset
233 end Restore_Initial_Environment;
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 procedure Verify_Files (O_File, E_File_1, E_File_2 : in File_Type) is
kono
parents:
diff changeset
238 Str_1, Str_2, Str_3, Str_4, Str_5, Str_6 : String (1..80);
kono
parents:
diff changeset
239 Len_1, Len_2, Len_3, Len_4, Len_5, Len_6 : Natural;
kono
parents:
diff changeset
240 begin
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 -- Get the lines that are contained in all the files, and verify
kono
parents:
diff changeset
243 -- them against the expected results.
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 Get_Line(O_File, Str_1, Len_1); -- The user defined output file
kono
parents:
diff changeset
246 Get_Line(O_File, Str_2, Len_2); -- should contain two lines of data.
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 if Str_1(1..Len_1) /= Line_1 or
kono
parents:
diff changeset
249 Str_2(1..Len_2) /= Line_2
kono
parents:
diff changeset
250 then
kono
parents:
diff changeset
251 Report.Failed("Incorrect results from Current_Output file");
kono
parents:
diff changeset
252 end if;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 Get_Line(E_File_1, Str_3, Len_3); -- The first error file received
kono
parents:
diff changeset
255 Get_Line(E_File_1, Str_4, Len_4); -- two lines of data originally,
kono
parents:
diff changeset
256 Get_Line(E_File_1, Str_5, Len_5); -- then had two additional lines
kono
parents:
diff changeset
257 Get_Line(E_File_1, Str_6, Len_6); -- appended from the second error
kono
parents:
diff changeset
258 -- file.
kono
parents:
diff changeset
259 if Str_3(1..Len_3) /= Line_3 or
kono
parents:
diff changeset
260 Str_4(1..Len_4) /= Line_4 or
kono
parents:
diff changeset
261 Str_5(1..Len_5) /= Line_5 or
kono
parents:
diff changeset
262 Str_6(1..Len_6) /= Line_6
kono
parents:
diff changeset
263 then
kono
parents:
diff changeset
264 Report.Failed("Incorrect results from first Error file");
kono
parents:
diff changeset
265 end if;
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 Get_Line(E_File_2, Str_5, Len_5); -- The second error file
kono
parents:
diff changeset
268 Get_Line(E_File_2, Str_6, Len_6); -- received two lines of data.
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 if Str_5(1..Len_5) /= Line_5 or
kono
parents:
diff changeset
271 Str_6(1..Len_6) /= Line_6
kono
parents:
diff changeset
272 then
kono
parents:
diff changeset
273 Report.Failed("Incorrect results from second Error file");
kono
parents:
diff changeset
274 end if;
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 end Verify_Files;
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 begin
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 Check_Initial_Environment (Initial_Environment);
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 -- Create user-defined text files that will be set to serve as current
kono
parents:
diff changeset
285 -- system input, output, and error files.
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 New_File (New_Input_File, Out_File, 1); -- Will be reset prior to use.
kono
parents:
diff changeset
288 New_File (New_Output_File, Out_File, 2);
kono
parents:
diff changeset
289 New_File (New_Error_File_1, Out_File, 3);
kono
parents:
diff changeset
290 New_File (New_Error_File_2, Out_File, 4);
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 -- Enter several lines of text into the new input file. This file will
kono
parents:
diff changeset
293 -- be reset to mode In_File to function as the current system input file.
kono
parents:
diff changeset
294 -- Note: File_Access value used as parameter to this procedure.
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 Load_Input_File (New_Input_Ptr);
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 -- Reset the New_Input_File to mode In_File, to allow it to act as the
kono
parents:
diff changeset
299 -- current system input file.
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 Reset1:
kono
parents:
diff changeset
302 begin
kono
parents:
diff changeset
303 Reset (New_Input_File, In_File);
kono
parents:
diff changeset
304 exception
kono
parents:
diff changeset
305 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
306 Report.Not_Applicable
kono
parents:
diff changeset
307 ( "Reset to In_File not supported for Text_IO - 1" );
kono
parents:
diff changeset
308 raise No_Reset;
kono
parents:
diff changeset
309 end Reset1;
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 -- Establish new files that will function as the current system Input,
kono
parents:
diff changeset
312 -- Output, and Error files.
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 Set_Input (New_Input_File);
kono
parents:
diff changeset
315 Set_Output(New_Output_Ptr.all);
kono
parents:
diff changeset
316 Set_Error (New_Error_Ptr.all);
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 -- Perform various file processing tasks, exercising specific new
kono
parents:
diff changeset
319 -- Text_IO functionality.
kono
parents:
diff changeset
320 --
kono
parents:
diff changeset
321 -- Read two lines from Current_Input and write them to Current_Output.
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 for i in 1..2 loop
kono
parents:
diff changeset
324 Get_Line(Current_Input, Line, Length);
kono
parents:
diff changeset
325 Put_Line(Current_Output, Line(1..Length));
kono
parents:
diff changeset
326 end loop;
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 -- Read two lines from Current_Input and write them to Current_Error.
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 for i in 1..2 loop
kono
parents:
diff changeset
331 Get_Line(Current_Input, Line, Length);
kono
parents:
diff changeset
332 Put_Line(Current_Error, Line(1..Length));
kono
parents:
diff changeset
333 end loop;
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 -- Reset the Current system error file.
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 Set_Error (New_Error_File_2);
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 -- Read two lines from Current_Input and write them to Current_Error.
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 for i in 1..2 loop
kono
parents:
diff changeset
342 Get_Line(Current_Input, Line, Length);
kono
parents:
diff changeset
343 Put_Line(Current_Error, Line(1..Length));
kono
parents:
diff changeset
344 end loop;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 -- At this point in the processing, the new Output file, and each of
kono
parents:
diff changeset
347 -- the two Error files, contain two lines of data.
kono
parents:
diff changeset
348 -- Note that New_Error_File_1 has been replaced by New_Error_File_2
kono
parents:
diff changeset
349 -- as the current system error file, allowing New_Error_File_1 to be
kono
parents:
diff changeset
350 -- reset (Mode_Error raised otherwise).
kono
parents:
diff changeset
351 --
kono
parents:
diff changeset
352 -- Reset the first Error file to Append_File mode, and then set it to
kono
parents:
diff changeset
353 -- function as the current system error file.
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 Reset2:
kono
parents:
diff changeset
356 begin
kono
parents:
diff changeset
357 Reset (New_Error_File_1, Append_File);
kono
parents:
diff changeset
358 exception
kono
parents:
diff changeset
359 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
360 Report.Not_Applicable
kono
parents:
diff changeset
361 ( "Reset to Append_File not supported for Text_IO - 2" );
kono
parents:
diff changeset
362 raise No_Reset;
kono
parents:
diff changeset
363 end Reset2;
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 Set_Error (New_Error_File_1);
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 -- Reset the second Error file to In_File mode, then set it to become
kono
parents:
diff changeset
368 -- the current system input file.
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 Reset3:
kono
parents:
diff changeset
371 begin
kono
parents:
diff changeset
372 Reset (New_Error_File_2, In_File);
kono
parents:
diff changeset
373 exception
kono
parents:
diff changeset
374 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
375 Report.Not_Applicable
kono
parents:
diff changeset
376 ( "Reset to In_File not supported for Text_IO - 3" );
kono
parents:
diff changeset
377 raise No_Reset;
kono
parents:
diff changeset
378 end Reset3;
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 New_Error_Ptr := New_Error_File_2'Access;
kono
parents:
diff changeset
381 Set_Input (New_Error_Ptr.all);
kono
parents:
diff changeset
382
kono
parents:
diff changeset
383 -- Append all of the text lines (2) in the new current system input
kono
parents:
diff changeset
384 -- file onto the current system error file.
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 while not End_Of_File(Current_Input) loop
kono
parents:
diff changeset
387 Get_Line(Current_Input, Line, Length);
kono
parents:
diff changeset
388 Put_Line(Current_Error, Line(1..Length));
kono
parents:
diff changeset
389 end loop;
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 -- Restore the original system file environment, based upon the values
kono
parents:
diff changeset
392 -- stored at the start of this test.
kono
parents:
diff changeset
393 -- Check that the original environment has been restored.
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 Restore_Initial_Environment (Initial_Environment);
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 -- Reset all three files to In_File_Mode prior to verification.
kono
parents:
diff changeset
398 -- Note: If these three files had still been the designated Current
kono
parents:
diff changeset
399 -- Input, Output, or Error files for the system, a Reset
kono
parents:
diff changeset
400 -- operation at this point would raise Mode_Error.
kono
parents:
diff changeset
401 -- However, at this point, the environment has been restored to
kono
parents:
diff changeset
402 -- its original state, and these user-defined files are no longer
kono
parents:
diff changeset
403 -- designated as current system files, allowing a Reset.
kono
parents:
diff changeset
404
kono
parents:
diff changeset
405 Reset4:
kono
parents:
diff changeset
406 begin
kono
parents:
diff changeset
407 Reset(New_Error_File_1, In_File);
kono
parents:
diff changeset
408 exception
kono
parents:
diff changeset
409 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
410 Report.Not_Applicable
kono
parents:
diff changeset
411 ( "Reset to In_File not supported for Text_IO - 4" );
kono
parents:
diff changeset
412 raise No_Reset;
kono
parents:
diff changeset
413 end Reset4;
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 Reset5:
kono
parents:
diff changeset
416 begin
kono
parents:
diff changeset
417 Reset(New_Error_File_2, In_File);
kono
parents:
diff changeset
418 exception
kono
parents:
diff changeset
419 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
420 Report.Not_Applicable
kono
parents:
diff changeset
421 ( "Reset to In_File not supported for Text_IO - 5" );
kono
parents:
diff changeset
422 raise No_Reset;
kono
parents:
diff changeset
423 end Reset5;
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 Reset6:
kono
parents:
diff changeset
426 begin
kono
parents:
diff changeset
427 Reset(New_Output_File, In_File);
kono
parents:
diff changeset
428 exception
kono
parents:
diff changeset
429 when Ada.Text_IO.Use_Error =>
kono
parents:
diff changeset
430 Report.Not_Applicable
kono
parents:
diff changeset
431 ( "Reset to In_File not supported for Text_IO - 6" );
kono
parents:
diff changeset
432 raise No_Reset;
kono
parents:
diff changeset
433 end Reset6;
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 -- Check that all the files contain the appropriate data.
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 Verify_Files (New_Output_File, New_Error_File_1, New_Error_File_2);
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 exception
kono
parents:
diff changeset
440 when No_Reset =>
kono
parents:
diff changeset
441 null;
kono
parents:
diff changeset
442 when Non_Applicable_System =>
kono
parents:
diff changeset
443 Report.Not_Applicable("System not capable of supporting external " &
kono
parents:
diff changeset
444 "text files -- Name_Error/Use_Error raised " &
kono
parents:
diff changeset
445 "during text file creation");
kono
parents:
diff changeset
446 Not_Applicable_System := True;
kono
parents:
diff changeset
447 when The_Error : others =>
kono
parents:
diff changeset
448 Report.Failed ("The following exception was raised in the " &
kono
parents:
diff changeset
449 "Test_Block: " & Exception_Name(The_Error));
kono
parents:
diff changeset
450 end Test_Block;
kono
parents:
diff changeset
451
kono
parents:
diff changeset
452 Delete_Block:
kono
parents:
diff changeset
453 begin
kono
parents:
diff changeset
454 Delete_File ( New_Input_File, 1 );
kono
parents:
diff changeset
455 Delete_File ( New_Output_File, 2 );
kono
parents:
diff changeset
456 Delete_File ( New_Error_File_1, 3 );
kono
parents:
diff changeset
457 Delete_File ( New_Error_File_2, 4 );
kono
parents:
diff changeset
458 end Delete_Block;
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 Report.Result;
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 end CXAA016;