annotate gcc/testsuite/ada/acats/tests/ca/ca11010.a @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- CA11010.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 a private child package can use entities declared in the
kono
parents:
diff changeset
28 -- private part of its parent unit.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- TEST DESCRIPTION:
kono
parents:
diff changeset
31 -- Declare a parent package containing private types, objects,
kono
parents:
diff changeset
32 -- and functions used by the system. Declare a private child package that
kono
parents:
diff changeset
33 -- uses the parent components to provide functionality to the system.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Declare an array of files with default values for all
kono
parents:
diff changeset
36 -- component fields of the files (records). Check the initial state of
kono
parents:
diff changeset
37 -- a specified file for proper default values. Perform the file "creation"
kono
parents:
diff changeset
38 -- (initialization), which will modify the fields of the record object.
kono
parents:
diff changeset
39 -- Again verify the file object to determine whether the fields have been
kono
parents:
diff changeset
40 -- reset properly.
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 --
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 package CA11010_0 is -- Package OS.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 type File_Descriptor_Type is private;
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 Default_Descriptor : constant File_Descriptor_Type;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 function Initialize_File return File_Descriptor_Type;
kono
parents:
diff changeset
54 procedure Verify_Initial_Conditions (Status : out Boolean);
kono
parents:
diff changeset
55 function Final_Conditions_Valid return Boolean;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 private
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 type File_Descriptor_Type is new Integer;
kono
parents:
diff changeset
60 type File_Name_Type is new String (1 .. 11);
kono
parents:
diff changeset
61 type Permission_Type is (None, User, System);
kono
parents:
diff changeset
62 type File_Mode_Type is (Read_Only, Write_Only, Read_Write);
kono
parents:
diff changeset
63 type File_Status_Type is (Open, Closed);
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 Default_Descriptor : constant File_Descriptor_Type := 0;
kono
parents:
diff changeset
66 Default_Permission : constant Permission_Type := None;
kono
parents:
diff changeset
67 Default_Mode : constant File_Mode_Type := Read_Only;
kono
parents:
diff changeset
68 Default_Status : constant File_Status_Type := Closed;
kono
parents:
diff changeset
69 Default_Filename : constant File_Name_Type := " ";
kono
parents:
diff changeset
70 An_Ada_File_Name : constant File_Name_Type := "AdaFileName";
kono
parents:
diff changeset
71 Max_Files : constant File_Descriptor_Type := 100;
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 type File_Type is tagged
kono
parents:
diff changeset
74 record
kono
parents:
diff changeset
75 Descriptor : File_Descriptor_Type := Default_Descriptor;
kono
parents:
diff changeset
76 Name : File_Name_Type := Default_Filename;
kono
parents:
diff changeset
77 Acct_Access : Permission_Type := Default_Permission;
kono
parents:
diff changeset
78 Mode : File_Mode_Type := Default_Mode;
kono
parents:
diff changeset
79 Current_Status : File_Status_Type := Default_Status;
kono
parents:
diff changeset
80 end record;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 type File_Array_Type is array (1 .. Max_Files) of File_Type;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 File_Table : File_Array_Type;
kono
parents:
diff changeset
85 File_Counter : Integer := 0;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 --
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 function Get_File_Name return File_Name_Type;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 end CA11010_0; -- Package OS.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 --=================================================================--
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 -- Subprograms that perform the actual file operations are contained in a
kono
parents:
diff changeset
96 -- private package so that they are not accessible to any client.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 private package CA11010_0.CA11010_1 is -- Package OS.Internals
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 Private_File_Counter : Integer renames File_Counter; -- Parent priv. object.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 function Initialize
kono
parents:
diff changeset
103 (File_Name : File_Name_Type := Get_File_Name; -- Parent priv. function.
kono
parents:
diff changeset
104 File_Mode : File_Mode_Type := Read_Write) -- Parent priv. literal.
kono
parents:
diff changeset
105 return File_Descriptor_Type; -- Parent type.
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 end CA11010_0.CA11010_1; -- Package OS.Internals
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 --=================================================================--
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 package body CA11010_0.CA11010_1 is -- Package body OS.Internals
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 function Next_Available_File return File_Descriptor_Type is
kono
parents:
diff changeset
114 begin
kono
parents:
diff changeset
115 Private_File_Counter := Private_File_Counter + 1;
kono
parents:
diff changeset
116 return (File_Descriptor_Type(File_Counter));
kono
parents:
diff changeset
117 end Next_Available_File;
kono
parents:
diff changeset
118 ----------------------------------------------------------------
kono
parents:
diff changeset
119 function Initialize
kono
parents:
diff changeset
120 (File_Name : File_Name_Type := Get_File_Name; -- Parent priv. function
kono
parents:
diff changeset
121 File_Mode : File_Mode_Type := Read_Write) -- Parent priv. literal
kono
parents:
diff changeset
122 return File_Descriptor_Type is -- Parent type
kono
parents:
diff changeset
123 Number : File_Descriptor_Type;
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125 Number := Next_Available_File;
kono
parents:
diff changeset
126 File_Table(Number).Descriptor := Number; -- Parent priv. object
kono
parents:
diff changeset
127 File_Table(Number).Name := File_Name; -- Default parameter value
kono
parents:
diff changeset
128 File_Table(Number).Mode := File_Mode; -- Default parameter value
kono
parents:
diff changeset
129 File_Table(Number).Acct_Access := User;
kono
parents:
diff changeset
130 File_Table(Number).Current_Status := Open;
kono
parents:
diff changeset
131 return (Number);
kono
parents:
diff changeset
132 end Initialize;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 end CA11010_0.CA11010_1; -- Package body OS.Internals
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 --=================================================================--
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 with CA11010_0.CA11010_1; -- Private child package "withed" by
kono
parents:
diff changeset
139 -- parent body.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 package body CA11010_0 is -- Package body OS
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 function Get_File_Name return File_Name_Type is
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 return (An_Ada_File_Name); -- If this was a real function, the user
kono
parents:
diff changeset
146 end Get_File_Name; -- would be asked to input a name, or there
kono
parents:
diff changeset
147 -- would be some type of similar processing.
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 -- This subprogram utilizes a call to a subprogram contained in a private
kono
parents:
diff changeset
150 -- child to perform the actual processing.
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 function Initialize_File return File_Descriptor_Type is
kono
parents:
diff changeset
153 begin
kono
parents:
diff changeset
154 return (CA11010_0.CA11010_1.Initialize); -- No parameters are needed,
kono
parents:
diff changeset
155 -- since defaults have been
kono
parents:
diff changeset
156 -- provided.
kono
parents:
diff changeset
157 end Initialize_File;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 --
kono
parents:
diff changeset
160 -- Separate subunits.
kono
parents:
diff changeset
161 --
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 procedure Verify_Initial_Conditions (Status : out Boolean) is separate;
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 function Final_Conditions_Valid return Boolean is separate;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 end CA11010_0; -- Package body OS
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 --=================================================================--
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 separate (CA11010_0)
kono
parents:
diff changeset
172 procedure Verify_Initial_Conditions (Status : out Boolean) is
kono
parents:
diff changeset
173 begin
kono
parents:
diff changeset
174 Status := False;
kono
parents:
diff changeset
175 if (File_Table(1).Descriptor = Default_Descriptor) and then
kono
parents:
diff changeset
176 (File_Table(1).Name = Default_Filename) and then
kono
parents:
diff changeset
177 (File_Table(1).Acct_Access = Default_Permission) and then
kono
parents:
diff changeset
178 (File_Table(1).Mode = Default_Mode) and then
kono
parents:
diff changeset
179 (File_Table(1).Current_Status = Default_Status)
kono
parents:
diff changeset
180 then
kono
parents:
diff changeset
181 Status := True;
kono
parents:
diff changeset
182 end if;
kono
parents:
diff changeset
183 end Verify_Initial_Conditions;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 --=================================================================--
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 separate (CA11010_0)
kono
parents:
diff changeset
188 function Final_Conditions_Valid return Boolean is
kono
parents:
diff changeset
189 begin
kono
parents:
diff changeset
190 if ((File_Table(1).Descriptor /= Default_Descriptor) and then
kono
parents:
diff changeset
191 (File_Table(1).Name = An_Ada_File_Name) and then
kono
parents:
diff changeset
192 (File_Table(1).Acct_Access = User) and then
kono
parents:
diff changeset
193 not ((File_Table(1).Mode = Default_Mode) or else
kono
parents:
diff changeset
194 (File_Table(1).Current_Status = Default_Status)))
kono
parents:
diff changeset
195 then
kono
parents:
diff changeset
196 return (True);
kono
parents:
diff changeset
197 else
kono
parents:
diff changeset
198 return (False);
kono
parents:
diff changeset
199 end if;
kono
parents:
diff changeset
200 end Final_Conditions_Valid;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 --=================================================================--
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 with CA11010_0; -- with Package OS.
kono
parents:
diff changeset
205 with Report;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 procedure CA11010 is
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 package OS renames CA11010_0;
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 Ada_File_Key : OS.File_Descriptor_Type := OS.Default_Descriptor;
kono
parents:
diff changeset
212 Initialization_Status : Boolean := False;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 begin
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 -- This test indicates one approach to a file management operation.
kono
parents:
diff changeset
217 -- It is not intended to demonstrate full functionality, but rather
kono
parents:
diff changeset
218 -- that the use of a private child package can provide a solution
kono
parents:
diff changeset
219 -- to a user situation, that being the implementation of certain functions
kono
parents:
diff changeset
220 -- being provided in a child package, with the parent package body
kono
parents:
diff changeset
221 -- utilizing these implementations.
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 Report.Test ("CA11010", "Check that a private child package can use " &
kono
parents:
diff changeset
224 "entities declared in the private part of its " &
kono
parents:
diff changeset
225 "parent unit");
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 -- Check initial conditions of the first entry in the file table.
kono
parents:
diff changeset
228 -- These are all default values provided in the declaration of the
kono
parents:
diff changeset
229 -- type File_Type.
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 OS.Verify_Initial_Conditions (Initialization_Status);
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 if not Initialization_Status then
kono
parents:
diff changeset
234 Report.Failed ("Initial condition failure");
kono
parents:
diff changeset
235 end if;
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 -- Call the initialization function. This will result in the resetting
kono
parents:
diff changeset
238 -- of the fields associated with the first entry in the File_Table (this
kono
parents:
diff changeset
239 -- is the first/only call of Initialize_File).
kono
parents:
diff changeset
240 -- No parameters are necessary for this call, due to the default values
kono
parents:
diff changeset
241 -- provided in the private child package routine Initialize.
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 Ada_File_Key := OS.Initialize_File;
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 -- Verify that the initial conditions of the file table component have
kono
parents:
diff changeset
246 -- been properly modified by the initialization function.
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 if not OS.Final_Conditions_Valid then
kono
parents:
diff changeset
249 Report.Failed ("Initialization processing failure");
kono
parents:
diff changeset
250 end if;
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 Report.Result;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 end CA11010;