annotate gcc/testsuite/ada/acats/tests/cxa/cxaa002.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 -- CXAA002.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 created with mode
kono
parents:
diff changeset
29 -- 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 creation 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 created 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 created 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 created with
kono
parents:
diff changeset
38 -- mode Append_File.
kono
parents:
diff changeset
39 -- Check that the procedure Set_Col sets the current column number to
kono
parents:
diff changeset
40 -- the value specified by the parameter "To" for text files created with
kono
parents:
diff changeset
41 -- mode Append_File.
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- TEST DESCRIPTION:
kono
parents:
diff changeset
44 -- This test is designed to simulate the text processing that could
kono
parents:
diff changeset
45 -- occur with files that have been created in Append_File mode. Various
kono
parents:
diff changeset
46 -- calls to Text_IO formatting subprograms are called to properly
kono
parents:
diff changeset
47 -- position text appended to a document. The text content and position
kono
parents:
diff changeset
48 -- are subsequently verified for accuracy.
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
51 -- This test is applicable only to implementations that support text
kono
parents:
diff changeset
52 -- files.
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- CHANGE HISTORY:
kono
parents:
diff changeset
56 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
57 -- 27 Feb 97 PWB.CTA Allowed for non-support of some IO operations
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 --!
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 with Ada.Text_IO;
kono
parents:
diff changeset
62 with Report;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 procedure CXAA002 is
kono
parents:
diff changeset
65 use Ada;
kono
parents:
diff changeset
66 Data_File : Text_IO.File_Type;
kono
parents:
diff changeset
67 Data_Filename : constant String :=
kono
parents:
diff changeset
68 Report.Legal_File_Name ( Nam => "CXAA002" );
kono
parents:
diff changeset
69 Incomplete : exception;
kono
parents:
diff changeset
70 begin
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 Report.Test ("CXAA002", "Check that page, line, and column formatting " &
kono
parents:
diff changeset
73 "subprograms perform properly on text files " &
kono
parents:
diff changeset
74 "created with mode Append_File");
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 Test_for_Text_IO_Support:
kono
parents:
diff changeset
77 begin
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 -- An implementation that does not support Text_IO in a particular
kono
parents:
diff changeset
80 -- environment will raise Use_Error on calls to various
kono
parents:
diff changeset
81 -- Text_IO operations. This block statement encloses a call to
kono
parents:
diff changeset
82 -- Create, which should raise the exception in a non-supportive
kono
parents:
diff changeset
83 -- environment. This exception will be handled to produce a
kono
parents:
diff changeset
84 -- Not_Applicable result.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 Text_IO.Create (File => Data_File,
kono
parents:
diff changeset
87 Mode => Text_IO.Append_File,
kono
parents:
diff changeset
88 Name => Data_Filename);
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 exception
kono
parents:
diff changeset
91
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 ( "Files not supported - Create as Append_File for Text_IO" );
kono
parents:
diff changeset
95 raise Incomplete;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 end Test_for_Text_IO_Support;
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 Operational_Test_Block:
kono
parents:
diff changeset
100 declare
kono
parents:
diff changeset
101 Default_Position : constant Text_IO.Positive_Count := 1;
kono
parents:
diff changeset
102 Section_Header : constant String := "VII. ";
kono
parents:
diff changeset
103 Appendix_Title : constant String := "Appendix A";
kono
parents:
diff changeset
104 Appendix_Content : constant String := "TBD";
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- The following procedure simulates the addition of an Appendix page
kono
parents:
diff changeset
107 -- to an existing text file.
kono
parents:
diff changeset
108 procedure Position_Appendix_Text is
kono
parents:
diff changeset
109 use Text_IO; -- To provide visibility to the "/=" operator.
kono
parents:
diff changeset
110 begin
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- Test control code.
kono
parents:
diff changeset
113 -- Verify initial page, line, column number.
kono
parents:
diff changeset
114 if "/="(Text_IO.Page (Data_File), Default_Position) then
kono
parents:
diff changeset
115 Report.Failed ("Incorrect default page number");
kono
parents:
diff changeset
116 end if;
kono
parents:
diff changeset
117 if Text_IO.Line (Data_File) /= Default_Position then
kono
parents:
diff changeset
118 Report.Failed ("Incorrect default line number");
kono
parents:
diff changeset
119 end if;
kono
parents:
diff changeset
120 if "/="(Text_IO.Col (Data_File), Default_Position) then
kono
parents:
diff changeset
121 Report.Failed ("Incorrect default column number");
kono
parents:
diff changeset
122 end if;
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 -- Simulated usage code.
kono
parents:
diff changeset
125 -- Set new page/line positions.
kono
parents:
diff changeset
126 Text_IO.Put_Line
kono
parents:
diff changeset
127 (Data_File, "Add some optional data to the file here");
kono
parents:
diff changeset
128 Text_IO.New_Page (Data_File);
kono
parents:
diff changeset
129 Text_IO.New_Line (File => Data_File, Spacing => 2);
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 -- Test control code.
kono
parents:
diff changeset
132 if Integer(Text_IO.Page (Data_File)) /= Report.Ident_Int(2) or else
kono
parents:
diff changeset
133 Integer(Text_IO.Line (Data_File)) /= Report.Ident_Int(3) then
kono
parents:
diff changeset
134 Report.Failed ("Incorrect results from page/line positioning");
kono
parents:
diff changeset
135 end if;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- Simulated usage code.
kono
parents:
diff changeset
138 Text_IO.Put (Data_File, Section_Header); -- Position title
kono
parents:
diff changeset
139 Text_IO.Put_Line (Data_File, Appendix_Title); -- of Appendix.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 Text_IO.Set_Line (File => Data_File, To => 5); -- Set new
kono
parents:
diff changeset
142 Text_IO.Set_Col (File => Data_File, To => 8); -- position.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 -- Test control code.
kono
parents:
diff changeset
145 if (Integer(Text_IO.Line (Data_File)) /= Report.Ident_Int(5)) or
kono
parents:
diff changeset
146 (Integer(Text_IO.Col (Data_File)) /= Report.Ident_Int(8)) then
kono
parents:
diff changeset
147 Report.Failed ("Incorrect results from line/column positioning");
kono
parents:
diff changeset
148 end if;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 -- Simulated usage code. -- Position
kono
parents:
diff changeset
151 Text_IO.Put_Line (Data_File, Appendix_Content); -- content of
kono
parents:
diff changeset
152 -- Appendix.
kono
parents:
diff changeset
153 end Position_Appendix_Text;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 begin
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 -- This code section simulates a scenario that could occur in a
kono
parents:
diff changeset
158 -- text processing environment:
kono
parents:
diff changeset
159 -- A document is created/modified/edited Then...
kono
parents:
diff changeset
160 -- Text is to be appended to the document.
kono
parents:
diff changeset
161 -- A procedure is called to perform that operation.
kono
parents:
diff changeset
162 -- The position on the appended page is set, verified, and text is
kono
parents:
diff changeset
163 -- appended to the existing file.
kono
parents:
diff changeset
164 --
kono
parents:
diff changeset
165 -- Note: The text file has been originally created in Append_File
kono
parents:
diff changeset
166 -- mode, and has not been closed prior to this processing.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 Position_Appendix_Text;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 Test_Verification_Block:
kono
parents:
diff changeset
171 declare
kono
parents:
diff changeset
172 TC_Page,
kono
parents:
diff changeset
173 TC_Line,
kono
parents:
diff changeset
174 TC_Column : Text_IO.Positive_Count;
kono
parents:
diff changeset
175 TC_Position : Natural := 0;
kono
parents:
diff changeset
176 Blanks : constant String := " ";
kono
parents:
diff changeset
177 TC_String : String (1 .. 17) := Blanks;
kono
parents:
diff changeset
178 begin
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 Reset1:
kono
parents:
diff changeset
181 begin
kono
parents:
diff changeset
182 Text_IO.Reset (Data_File, Text_IO.In_File);
kono
parents:
diff changeset
183 exception
kono
parents:
diff changeset
184 when Text_IO.Use_Error =>
kono
parents:
diff changeset
185 Report.Not_Applicable
kono
parents:
diff changeset
186 ( "Reset to In_File not supported for Text_IO" );
kono
parents:
diff changeset
187 raise Incomplete;
kono
parents:
diff changeset
188 end Reset1;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 Text_IO.Skip_Page (Data_File);
kono
parents:
diff changeset
191 -- Loop to the third line
kono
parents:
diff changeset
192 for I in 1 .. 3 loop -- and read the contents.
kono
parents:
diff changeset
193 Text_IO.Get_Line (Data_File, TC_String, TC_Position);
kono
parents:
diff changeset
194 end loop;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 if (TC_Position /= 16) or else -- Verify the title line.
kono
parents:
diff changeset
197 (TC_String (1..4) /= "VII.") or else
kono
parents:
diff changeset
198 (TC_String (3..16) /= ("I. " & Appendix_Title)) then
kono
parents:
diff changeset
199 Report.Failed ("Incorrect positioning of title line");
kono
parents:
diff changeset
200 end if;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 TC_String := Blanks; -- Clear string.
kono
parents:
diff changeset
203 -- Loop to the fifth line
kono
parents:
diff changeset
204 for I in 4 .. 5 loop -- and read the contents.
kono
parents:
diff changeset
205 Text_IO.Get_Line (Data_File, TC_String, TC_Position);
kono
parents:
diff changeset
206 end loop;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 if (TC_Position /= 10) or -- Verify the contents.
kono
parents:
diff changeset
209 (TC_String (8..10) /= Appendix_Content) then
kono
parents:
diff changeset
210 Report.Failed ("Incorrect positioning of contents line");
kono
parents:
diff changeset
211 end if;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 exception
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 when Incomplete =>
kono
parents:
diff changeset
216 raise;
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 when others =>
kono
parents:
diff changeset
219 Report.Failed ("Error raised during data verification");
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 end Test_Verification_Block;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 exception
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 when Incomplete =>
kono
parents:
diff changeset
226 raise;
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 when others =>
kono
parents:
diff changeset
229 Report.Failed ("Exception raised during Text_IO processing");
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 end Operational_Test_Block;
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 Deletion:
kono
parents:
diff changeset
234 begin
kono
parents:
diff changeset
235 -- Delete the external file.
kono
parents:
diff changeset
236 if Text_IO.Is_Open(Data_File) then
kono
parents:
diff changeset
237 Text_IO.Delete(Data_File);
kono
parents:
diff changeset
238 else
kono
parents:
diff changeset
239 Text_IO.Open(Data_File, Text_IO.In_File, Data_Filename);
kono
parents:
diff changeset
240 Text_IO.Delete(Data_File);
kono
parents:
diff changeset
241 end if;
kono
parents:
diff changeset
242 exception
kono
parents:
diff changeset
243 when others =>
kono
parents:
diff changeset
244 Report.Failed
kono
parents:
diff changeset
245 ( "Delete not properly implemented for Text_IO" );
kono
parents:
diff changeset
246 end Deletion;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 Report.Result;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 exception
kono
parents:
diff changeset
251 when Incomplete =>
kono
parents:
diff changeset
252 Report.Result;
kono
parents:
diff changeset
253 when others =>
kono
parents:
diff changeset
254 Report.Failed ( "Unexpected exception" );
kono
parents:
diff changeset
255 Report.Result;
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 end CXAA002;