annotate gcc/testsuite/ada/acats/tests/cxa/cxaa013.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 -- CXAA013.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 exception Mode_Error is raised when an attempt is made
kono
parents:
diff changeset
28 -- to skip a line or page using the predefined Skip_Line and Skip_Page
kono
parents:
diff changeset
29 -- procedures on a text file with mode Append_File.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- TEST DESCRIPTION:
kono
parents:
diff changeset
32 -- A scenario is created that demonstrates the potential for the
kono
parents:
diff changeset
33 -- incorrect usage of predefined text processing subprograms, which
kono
parents:
diff changeset
34 -- results in the raising of a Mode_Error exception.
kono
parents:
diff changeset
35 -- A count is kept to ensure that each anticipated exception is in fact
kono
parents:
diff changeset
36 -- raised and handled properly.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- APPLICABILITY CRITERIA:
kono
parents:
diff changeset
39 -- This test is applicable only to implementations that support text
kono
parents:
diff changeset
40 -- files.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 -- CHANGE HISTORY:
kono
parents:
diff changeset
44 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
45 -- 28 Feb 97 PWB.CTA Allowed for non-support of some IO operations
kono
parents:
diff changeset
46 --!
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 with Ada.Text_IO;
kono
parents:
diff changeset
49 with Report;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 procedure CXAA013 is
kono
parents:
diff changeset
52 use Ada;
kono
parents:
diff changeset
53 Text_File : Text_IO.File_Type;
kono
parents:
diff changeset
54 Text_Filename : constant String :=
kono
parents:
diff changeset
55 Report.Legal_File_Name ( Nam => "CXAA013" );
kono
parents:
diff changeset
56 Incomplete : exception;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 begin
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 Report.Test ("CXAA013", "Check that the exception Mode_Error is " &
kono
parents:
diff changeset
61 "raised when an attempt is made to skip " &
kono
parents:
diff changeset
62 "a line or page using the predefined " &
kono
parents:
diff changeset
63 "Skip_Line and Skip_Page procedures on " &
kono
parents:
diff changeset
64 "a text file with mode Append_File");
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Test_for_Text_IO_Support:
kono
parents:
diff changeset
67 begin
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 -- An application creates a text file with mode Append_File.
kono
parents:
diff changeset
70 -- Use_Error will be raised if Text_IO operations or external files are not
kono
parents:
diff changeset
71 -- supported.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Text_IO.Create (Text_File, Text_IO.Append_File, Text_Filename);
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 exception
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 when Text_IO.Use_Error | Text_IO.Name_Error =>
kono
parents:
diff changeset
78 Report.Not_Applicable
kono
parents:
diff changeset
79 ( "Files not supported - Create as Append_File for Text_IO" );
kono
parents:
diff changeset
80 raise Incomplete;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 end Test_for_Text_IO_Support;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 -- The application writes some amount of data to the file.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 Text_IO.Put_Line (Text_File, "Data entered into the file");
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 Operational_Test_Block:
kono
parents:
diff changeset
89 declare
kono
parents:
diff changeset
90 TC_Number_Of_Forced_Mode_Errors : constant Natural := 2;
kono
parents:
diff changeset
91 TC_Mode_Errors : Natural := 0;
kono
parents:
diff changeset
92 begin
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Test_for_Skip_Line:
kono
parents:
diff changeset
95 declare
kono
parents:
diff changeset
96 TC_Spacing : constant Text_IO.Count := 3;
kono
parents:
diff changeset
97 begin
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 -- During the course of its processing, the application may attempt to
kono
parents:
diff changeset
100 -- invoke the Skip_Line procedure on a file that is currently in Append_File
kono
parents:
diff changeset
101 -- mode (instead of the anticipated In_File mode). This results in the
kono
parents:
diff changeset
102 -- raising of Mode_Error.
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 Text_IO.Skip_Line (Text_File, TC_Spacing);
kono
parents:
diff changeset
105 Report.Failed ("Exception not raised by Skip_Line");
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 -- An exception handler present within the application handles the exception
kono
parents:
diff changeset
108 -- and processing can continue.
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 exception
kono
parents:
diff changeset
111 when Text_IO.Mode_Error =>
kono
parents:
diff changeset
112 TC_Mode_Errors := TC_Mode_Errors + 1;
kono
parents:
diff changeset
113 when others =>
kono
parents:
diff changeset
114 Report.Failed("Exception in Skip_Line processing");
kono
parents:
diff changeset
115 end Test_for_Skip_Line;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 Test_for_Skip_Page:
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- Again, during the course of its processing, the application incorrectly
kono
parents:
diff changeset
121 -- assumes that the file mode is In_File, this time attempting to call the
kono
parents:
diff changeset
122 -- Skip_Page procedure for the file (that is currently in Append_File mode).
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 Text_IO.Skip_Page (Text_File);
kono
parents:
diff changeset
125 Report.Failed ("Exception not raised by Skip_Page");
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 -- Once again, an exception handler present within the application handles
kono
parents:
diff changeset
128 -- the exception and processing continues.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 exception
kono
parents:
diff changeset
131 when Text_IO.Mode_Error =>
kono
parents:
diff changeset
132 TC_Mode_Errors := TC_Mode_Errors + 1;
kono
parents:
diff changeset
133 when others =>
kono
parents:
diff changeset
134 Report.Failed("Exception in Skip_Page processing");
kono
parents:
diff changeset
135 end Test_for_Skip_Page;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 if (TC_Mode_Errors /= TC_Number_Of_Forced_Mode_Errors) then
kono
parents:
diff changeset
138 Report.Failed ("Incorrect number of exceptions handled");
kono
parents:
diff changeset
139 end if;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 end Operational_Test_Block;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 Deletion:
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 -- Delete the external file.
kono
parents:
diff changeset
146 if Text_IO.Is_Open (Text_File) then
kono
parents:
diff changeset
147 Text_IO.Delete (Text_File);
kono
parents:
diff changeset
148 else
kono
parents:
diff changeset
149 Text_IO.Open (Text_File, Text_IO.In_File, Text_Filename);
kono
parents:
diff changeset
150 Text_IO.Delete (Text_File);
kono
parents:
diff changeset
151 end if;
kono
parents:
diff changeset
152 exception
kono
parents:
diff changeset
153 when others =>
kono
parents:
diff changeset
154 Report.Failed
kono
parents:
diff changeset
155 ( "Delete not properly implemented for Text_IO" );
kono
parents:
diff changeset
156 end Deletion;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 Report.Result;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 exception
kono
parents:
diff changeset
161 when Incomplete =>
kono
parents:
diff changeset
162 Report.Result;
kono
parents:
diff changeset
163 when others =>
kono
parents:
diff changeset
164 Report.Failed ( "Unexpected exception" );
kono
parents:
diff changeset
165 Report.Result;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 end CXAA013;