annotate gcc/testsuite/ada/acats/tests/cxa/cxaa003.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 -- CXAA003.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 procedures New_Page, Set_Line, Set_Col, and New_Line
kono
parents:
diff changeset
28 -- subprograms perform properly on a text file reset (from Out_File)
kono
parents:
diff changeset
29 -- with mode Append_File.
kono
parents:
diff changeset
30 -- Check that the attributes Page, Line, and Column are all set to 1
kono
parents:
diff changeset
31 -- following the reset of a text file with mode Append_File.
kono
parents:
diff changeset
32 -- Check that the functions Page, Line, and Col perform properly on a
kono
parents:
diff changeset
33 -- text file reset with mode Append_File.
kono
parents:
diff changeset
34 -- Check that the procedures Put and Put_Line perform properly on text
kono
parents:
diff changeset
35 -- files reset with mode Append_File.
kono
parents:
diff changeset
36 -- Check that the procedure Set_Line sets the current line number to
kono
parents:
diff changeset
37 -- the value specified by the parameter "To" for text files reset with
kono
parents:
diff changeset
38 -- mode Append_File. Check that Set_Line has no effect if the specified
kono
parents:
diff changeset
39 -- line equals the current line.
kono
parents:
diff changeset
40 -- Check that the procedure Set_Col sets the current column number to
kono
parents:
diff changeset
41 -- the value specified by the parameter "To" for text files reset with
kono
parents:
diff changeset
42 -- mode Append_File.
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 -- TEST DESCRIPTION:
kono
parents:
diff changeset
45 -- This test is designed to simulate the text processing that could
kono
parents:
diff changeset
46 -- occur with files that have been created in Out_File mode,
kono
parents:
diff changeset
47 -- and then reset to Append_File mode.
kono
parents:
diff changeset
48 -- Various calls to Text_IO formatting subprograms are called to properly
kono
parents:
diff changeset
49 -- position text appended to a document. The text content and position
kono
parents:
diff changeset
50 -- are subsequently verified for accuracy.
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
53 -- This test is applicable only to implementations that support text
kono
parents:
diff changeset
54 -- files.
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 -- CHANGE HISTORY:
kono
parents:
diff changeset
58 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
59 -- 24 Feb 97 PWB.CTA Allowed for non-support of some IO operations.
kono
parents:
diff changeset
60 --!
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 with Ada.Text_IO;
kono
parents:
diff changeset
63 with Report;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure CXAA003 is
kono
parents:
diff changeset
66 use Ada;
kono
parents:
diff changeset
67 Data_File : Text_IO.File_Type;
kono
parents:
diff changeset
68 Data_Filename : constant String :=
kono
parents:
diff changeset
69 Report.Legal_File_Name ( Nam => "CXAA003" );
kono
parents:
diff changeset
70 Incomplete : exception;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 begin
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 Report.Test ("CXAA003", "Check that page, line, and column formatting " &
kono
parents:
diff changeset
75 "subprograms perform properly on text files " &
kono
parents:
diff changeset
76 "reset with mode Append_File");
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 Test_for_Text_IO_Support:
kono
parents:
diff changeset
79 begin
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- An implementation that does not support Text_IO in a particular
kono
parents:
diff changeset
82 -- environment will raise Use_Error on calls to various
kono
parents:
diff changeset
83 -- Text_IO operations. This block statement encloses a call to
kono
parents:
diff changeset
84 -- Create, which should raise the exception in a non-supportive
kono
parents:
diff changeset
85 -- environment. This exception will be handled to produce a
kono
parents:
diff changeset
86 -- Not_Applicable result.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Text_IO.Create (File => Data_File,
kono
parents:
diff changeset
89 Mode => Text_IO.Out_File,
kono
parents:
diff changeset
90 Name => Data_Filename);
kono
parents:
diff changeset
91 exception
kono
parents:
diff changeset
92 when Text_IO.Use_Error | Text_IO.Name_Error =>
kono
parents:
diff changeset
93 Report.Not_Applicable
kono
parents:
diff changeset
94 ( "Text files not supported - Create as Out_File" );
kono
parents:
diff changeset
95 raise Incomplete;
kono
parents:
diff changeset
96 end Test_for_Text_IO_Support;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 Operational_Test_Block:
kono
parents:
diff changeset
99 declare
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 Default_Position : constant Text_IO.Positive_Count := 1;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 Section_Header : constant String := "IX. ";
kono
parents:
diff changeset
104 Glossary_Title : constant String := "GLOSSARY";
kono
parents:
diff changeset
105 Glossary_Content : constant String := "TBD";
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 -- The following procedure simulates the addition of a Glossary page
kono
parents:
diff changeset
108 -- to an existing text file that has been reset with mode
kono
parents:
diff changeset
109 -- Append_File.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Position_Glossary_Text
kono
parents:
diff changeset
112 (The_File : in out Text_IO.File_Type) is
kono
parents:
diff changeset
113 use Text_IO; -- To provide visibility to the "/=" operator.
kono
parents:
diff changeset
114 begin
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 -- Test control code.
kono
parents:
diff changeset
117 -- Verify initial page value.
kono
parents:
diff changeset
118 if (Text_IO.Page (The_File) /= Default_Position) then
kono
parents:
diff changeset
119 Report.Failed ("Incorrect default page number");
kono
parents:
diff changeset
120 end if;
kono
parents:
diff changeset
121 -- Verify initial line number.
kono
parents:
diff changeset
122 if (Text_IO.Line (The_File) /= Default_Position) then
kono
parents:
diff changeset
123 Report.Failed ("Incorrect default line number");
kono
parents:
diff changeset
124 end if;
kono
parents:
diff changeset
125 -- Verify initial column number.
kono
parents:
diff changeset
126 if (Text_IO.Col (The_File) /= Default_Position) then
kono
parents:
diff changeset
127 Report.Failed ("Incorrect default column number");
kono
parents:
diff changeset
128 end if;
kono
parents:
diff changeset
129 -- Simulated usage code. Set new page/line positions.
kono
parents:
diff changeset
130 Text_IO.New_Page (The_File);
kono
parents:
diff changeset
131 Text_IO.New_Page (The_File);
kono
parents:
diff changeset
132 Text_IO.New_Line (File => The_File, Spacing => 1);
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 -- Test control code.
kono
parents:
diff changeset
135 if (Integer(Text_IO.Page(The_File)) /=
kono
parents:
diff changeset
136 Report.Ident_Int(3)) or else
kono
parents:
diff changeset
137 (Integer(Text_IO.Line (The_File)) /=
kono
parents:
diff changeset
138 Report.Ident_Int(2)) then
kono
parents:
diff changeset
139 Report.Failed ("Incorrect results from page/line positioning");
kono
parents:
diff changeset
140 end if;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 -- Simulated usage code. Position title of Glossary.
kono
parents:
diff changeset
143 Text_IO.Put (The_File, Section_Header);
kono
parents:
diff changeset
144 Text_IO.Put_Line (The_File, Glossary_Title);
kono
parents:
diff changeset
145 -- Set line to the current line.
kono
parents:
diff changeset
146 Text_IO.Set_Line (File => The_File, To => 3);
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 -- Test control code.
kono
parents:
diff changeset
149 if (Integer(Text_IO.Page (The_File)) /= Report.Ident_Int(3)) or
kono
parents:
diff changeset
150 (Integer(Text_IO.Line (The_File)) /= Report.Ident_Int(3)) or
kono
parents:
diff changeset
151 (Integer(Text_IO.Col (The_File)) /= Report.Ident_Int(1)) then
kono
parents:
diff changeset
152 Report.Failed ("Set_Line failed for current line");
kono
parents:
diff changeset
153 end if;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- Simulated usage code.
kono
parents:
diff changeset
156 Text_IO.Set_Line (File => The_File, To => 4); -- Set new
kono
parents:
diff changeset
157 Text_IO.Set_Col (File => The_File, To => 10); -- position.
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 -- Test control code.
kono
parents:
diff changeset
160 if (Integer(Text_IO.Line (The_File)) /= Report.Ident_Int(4)) or
kono
parents:
diff changeset
161 (Integer(Text_IO.Col (The_File)) /= Report.Ident_Int(10)) then
kono
parents:
diff changeset
162 Report.Failed
kono
parents:
diff changeset
163 ("Incorrect results from line/column positioning");
kono
parents:
diff changeset
164 end if;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- Simulated usage code. -- Position
kono
parents:
diff changeset
167 Text_IO.Put_Line (The_File, Glossary_Content); -- content of
kono
parents:
diff changeset
168 -- Glossary.
kono
parents:
diff changeset
169 end Position_Glossary_Text;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 begin
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 -- In the scenario, data is added to the file here.
kono
parents:
diff changeset
175 Text_IO.Put_Line (File => Data_File, Item => "Some optional data");
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 -- This code section simulates a scenario that could occur in a
kono
parents:
diff changeset
178 -- text processing environment. Text is to be appended to an
kono
parents:
diff changeset
179 -- existing document:
kono
parents:
diff changeset
180 -- The file is reset to append mode.
kono
parents:
diff changeset
181 -- A procedure is called to perform the positioning and placement
kono
parents:
diff changeset
182 -- of text.
kono
parents:
diff changeset
183 -- The position on the appended page is set, verified, and text is
kono
parents:
diff changeset
184 -- placed in the file.
kono
parents:
diff changeset
185 --
kono
parents:
diff changeset
186 -- Note: The text file has been originally created in Out_File
kono
parents:
diff changeset
187 -- mode, and has subsequently been reset to Append_File mode.
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 Reset1:
kono
parents:
diff changeset
190 begin
kono
parents:
diff changeset
191 -- Reset has effect of calling New_Page.
kono
parents:
diff changeset
192 Text_IO.Reset (Data_File, Text_IO.Append_File);
kono
parents:
diff changeset
193 exception
kono
parents:
diff changeset
194 when Text_IO.Use_Error =>
kono
parents:
diff changeset
195 Report.Not_Applicable
kono
parents:
diff changeset
196 ( "Reset to Append_File not supported for Text_IO" );
kono
parents:
diff changeset
197 raise Incomplete;
kono
parents:
diff changeset
198 end Reset1;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 Position_Glossary_Text (The_File => Data_File);
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 Test_Verification_Block:
kono
parents:
diff changeset
203 declare
kono
parents:
diff changeset
204 TC_Page, TC_Line, TC_Column : Text_IO.Positive_Count;
kono
parents:
diff changeset
205 TC_Position : Natural := 0;
kono
parents:
diff changeset
206 Blanks : constant String :=
kono
parents:
diff changeset
207 " ";
kono
parents:
diff changeset
208 TC_String : String (1 .. 15) := Blanks;
kono
parents:
diff changeset
209 begin
kono
parents:
diff changeset
210 Reset2:
kono
parents:
diff changeset
211 begin
kono
parents:
diff changeset
212 Text_IO.Reset (Data_File, Text_IO.In_File);
kono
parents:
diff changeset
213 exception
kono
parents:
diff changeset
214 when Text_IO.Use_Error =>
kono
parents:
diff changeset
215 Report.Not_Applicable
kono
parents:
diff changeset
216 ( "Reset to In_File not supported for Text_IO" );
kono
parents:
diff changeset
217 raise Incomplete;
kono
parents:
diff changeset
218 end Reset2;
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 Text_IO.Skip_Page (Data_File);
kono
parents:
diff changeset
221 Text_IO.Skip_Page (Data_File);
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 -- If the Reset to Append_File mode actually put a page terminator
kono
parents:
diff changeset
224 -- on the file, as allowed (but not required) by RM A.10.2(4), then
kono
parents:
diff changeset
225 -- we are now on page 3, an empty page. We'll need to skip one more.
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 if Text_IO.End_Of_Page (Data_File) then
kono
parents:
diff changeset
228 Text_IO.Skip_Page (Data_File);
kono
parents:
diff changeset
229 end if;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 -- Now we're on the Glossary page.
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 -- Loop to the second line
kono
parents:
diff changeset
234 for I in 1 .. 2 loop -- and read the contents.
kono
parents:
diff changeset
235 Text_IO.Get_Line (Data_File, TC_String, TC_Position);
kono
parents:
diff changeset
236 end loop;
kono
parents:
diff changeset
237 if (TC_Position /= 13) or else -- Verify the title line.
kono
parents:
diff changeset
238 (TC_String (1..2) /= "IX") or else
kono
parents:
diff changeset
239 (TC_String (3..13) /= (". " & Glossary_Title)) then
kono
parents:
diff changeset
240 Report.Failed ("Incorrect positioning of title line");
kono
parents:
diff changeset
241 end if;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 TC_String := Blanks; -- Clear string.
kono
parents:
diff changeset
244 -- Loop to the fourth line
kono
parents:
diff changeset
245 for I in 3 .. 4 loop -- and read the contents.
kono
parents:
diff changeset
246 Text_IO.Get_Line (Data_File, TC_String, TC_Position);
kono
parents:
diff changeset
247 end loop;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 if (TC_Position /= 12) or -- Verify the contents.
kono
parents:
diff changeset
250 (TC_String (8..12) /= " " & Glossary_Content) then
kono
parents:
diff changeset
251 Report.Failed ("Incorrect positioning of contents line");
kono
parents:
diff changeset
252 end if;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 exception
kono
parents:
diff changeset
255 when Incomplete =>
kono
parents:
diff changeset
256 raise;
kono
parents:
diff changeset
257 when others =>
kono
parents:
diff changeset
258 Report.Failed ("Error raised during data verification");
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 end Test_Verification_Block;
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 exception
kono
parents:
diff changeset
263 when Incomplete =>
kono
parents:
diff changeset
264 raise;
kono
parents:
diff changeset
265 when others =>
kono
parents:
diff changeset
266 Report.Failed ("Exception raised during Text_IO processing");
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 end Operational_Test_Block;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 Final_Block:
kono
parents:
diff changeset
271 begin
kono
parents:
diff changeset
272 -- Delete the external file.
kono
parents:
diff changeset
273 if Text_IO.Is_Open (Data_File) then
kono
parents:
diff changeset
274 Text_IO.Delete (Data_File);
kono
parents:
diff changeset
275 else
kono
parents:
diff changeset
276 Text_IO.Open (Data_File, Text_IO.In_File, Data_Filename);
kono
parents:
diff changeset
277 Text_IO.Delete (Data_File);
kono
parents:
diff changeset
278 end if;
kono
parents:
diff changeset
279 exception
kono
parents:
diff changeset
280 when others =>
kono
parents:
diff changeset
281 Report.Failed ( "Delete not properly implemented for Text_IO" );
kono
parents:
diff changeset
282 end Final_Block;
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 Report.Result;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 exception
kono
parents:
diff changeset
287 when Incomplete =>
kono
parents:
diff changeset
288 Report.Result;
kono
parents:
diff changeset
289 when others =>
kono
parents:
diff changeset
290 Report.Failed ( "Unexpected exception" );
kono
parents:
diff changeset
291 Report.Result;
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 end CXAA003;