annotate gcc/testsuite/ada/acats/tests/ca/ca11011.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 -- CA11011.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 the parent unit 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 and objects
kono
parents:
diff changeset
32 -- used by the system. Declare a public child package that
kono
parents:
diff changeset
33 -- provides a visible interface to the system functionality.
kono
parents:
diff changeset
34 -- Declare a private grandchild package that uses the visible grandparent
kono
parents:
diff changeset
35 -- components to provide the actual functionality to the system.
kono
parents:
diff changeset
36 --
kono
parents:
diff changeset
37 -- The public child (parent of the private grandchild) uses the
kono
parents:
diff changeset
38 -- functionality of its private child (grandchild package) to provide
kono
parents:
diff changeset
39 -- the visible interface to operations of the system.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- The test itself will utilize the visible interface provided in the
kono
parents:
diff changeset
42 -- public child package to demonstrate a possible solution to file
kono
parents:
diff changeset
43 -- management.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- CHANGE HISTORY:
kono
parents:
diff changeset
47 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 --!
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 package CA11011_0 is -- Package OS.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 type File_Descriptor_Type is private;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 Default_Descriptor : constant File_Descriptor_Type;
kono
parents:
diff changeset
56 First_File : constant File_Descriptor_Type;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 procedure Verify_Initial_Conditions (Key : in File_Descriptor_Type;
kono
parents:
diff changeset
59 Status : out Boolean);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 function Final_Conditions_Valid (Key : File_Descriptor_Type)
kono
parents:
diff changeset
62 return Boolean;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 private
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 type File_Descriptor_Type is new Integer;
kono
parents:
diff changeset
68 type File_Name_Type is new String (1 .. 11);
kono
parents:
diff changeset
69 type Permission_Type is (None, User, System);
kono
parents:
diff changeset
70 type File_Mode_Type is (Read_Only, Write_Only, Read_Write);
kono
parents:
diff changeset
71 type File_Status_Type is (Open, Closed);
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Default_Descriptor : constant File_Descriptor_Type := 0;
kono
parents:
diff changeset
74 First_File : constant File_Descriptor_Type := 1;
kono
parents:
diff changeset
75 Default_Permission : constant Permission_Type := None;
kono
parents:
diff changeset
76 Default_Mode : constant File_Mode_Type := Read_Only;
kono
parents:
diff changeset
77 Default_Status : constant File_Status_Type := Closed;
kono
parents:
diff changeset
78 Default_Filename : constant File_Name_Type := " ";
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 Init_Permission : constant Permission_Type := User;
kono
parents:
diff changeset
81 Init_Mode : constant File_Mode_Type := Read_Write;
kono
parents:
diff changeset
82 Init_Status : constant File_Status_Type := Open;
kono
parents:
diff changeset
83 An_Ada_File_Name : constant File_Name_Type := "AdaFileName";
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 Max_Files : constant File_Descriptor_Type := 10;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 type File_Type is tagged
kono
parents:
diff changeset
88 record
kono
parents:
diff changeset
89 Descriptor : File_Descriptor_Type := Default_Descriptor;
kono
parents:
diff changeset
90 Name : File_Name_Type := Default_Filename;
kono
parents:
diff changeset
91 Acct_Access : Permission_Type := Default_Permission;
kono
parents:
diff changeset
92 Mode : File_Mode_Type := Default_Mode;
kono
parents:
diff changeset
93 Current_Status : File_Status_Type := Default_Status;
kono
parents:
diff changeset
94 end record;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 type File_Array_Type is array (1 .. Max_Files) of File_Type;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 File_Table : File_Array_Type;
kono
parents:
diff changeset
99 File_Counter : Integer := 0;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 --
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 function Get_File_Name return File_Name_Type;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 end CA11011_0; -- Package OS.
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 --=================================================================--
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 package body CA11011_0 is -- Package body OS.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 function Get_File_Name return File_Name_Type is
kono
parents:
diff changeset
112 begin
kono
parents:
diff changeset
113 return (An_Ada_File_Name);
kono
parents:
diff changeset
114 end Get_File_Name;
kono
parents:
diff changeset
115 ---------------------------------------------------------------------
kono
parents:
diff changeset
116 procedure Verify_Initial_Conditions (Key : in File_Descriptor_Type;
kono
parents:
diff changeset
117 Status : out Boolean) is
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 Status := False;
kono
parents:
diff changeset
120 if (File_Table(Key).Descriptor = Default_Descriptor) and then
kono
parents:
diff changeset
121 (File_Table(Key).Name = Default_Filename) and then
kono
parents:
diff changeset
122 (File_Table(Key).Acct_Access = Default_Permission) and then
kono
parents:
diff changeset
123 (File_Table(Key).Mode = Default_Mode) and then
kono
parents:
diff changeset
124 (File_Table(Key).Current_Status = Default_Status)
kono
parents:
diff changeset
125 then
kono
parents:
diff changeset
126 Status := True;
kono
parents:
diff changeset
127 end if;
kono
parents:
diff changeset
128 end Verify_Initial_Conditions;
kono
parents:
diff changeset
129 ---------------------------------------------------------------------
kono
parents:
diff changeset
130 function Final_Conditions_Valid (Key : File_Descriptor_Type)
kono
parents:
diff changeset
131 return Boolean is
kono
parents:
diff changeset
132 begin
kono
parents:
diff changeset
133 if ((File_Table(Key).Descriptor = First_File) and then
kono
parents:
diff changeset
134 (File_Table(Key).Name = An_Ada_File_Name) and then
kono
parents:
diff changeset
135 (File_Table(Key).Acct_Access = Init_Permission) and then
kono
parents:
diff changeset
136 not ((File_Table(Key).Mode = Default_Mode) or else
kono
parents:
diff changeset
137 (File_Table(Key).Current_Status = Default_Status)))
kono
parents:
diff changeset
138 then
kono
parents:
diff changeset
139 return (True);
kono
parents:
diff changeset
140 else
kono
parents:
diff changeset
141 return (False);
kono
parents:
diff changeset
142 end if;
kono
parents:
diff changeset
143 end Final_Conditions_Valid;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 end CA11011_0; -- Package body OS.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 --=================================================================--
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 package CA11011_0.CA11011_1 is -- Package OS.File_Manager
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 procedure Create_File (File_Key : in File_Descriptor_Type);
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 end CA11011_0.CA11011_1; -- Package OS.File_Manager
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 --=================================================================--
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 -- The Subprogram that performs the actual file operations is contained in a
kono
parents:
diff changeset
158 -- private package so that it is not accessible to any client.
kono
parents:
diff changeset
159 -- Default parameters are used in most cases in the subprogram calls, since
kono
parents:
diff changeset
160 -- the caller does not have visibility to these private types.
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 -- Package OS.File_Manager.Internals
kono
parents:
diff changeset
163 private package CA11011_0.CA11011_1.CA11011_2 is
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 Private_File_Counter : Integer renames File_Counter; -- Grandparent
kono
parents:
diff changeset
166 -- object.
kono
parents:
diff changeset
167 procedure Create
kono
parents:
diff changeset
168 (Key : in File_Descriptor_Type;
kono
parents:
diff changeset
169 File_Name : in File_Name_Type := Get_File_Name; -- Grandparent
kono
parents:
diff changeset
170 -- prvt type,
kono
parents:
diff changeset
171 -- prvt functn.
kono
parents:
diff changeset
172 File_Mode : in File_Mode_Type := Init_Mode; -- Grandparent
kono
parents:
diff changeset
173 -- prvt type,
kono
parents:
diff changeset
174 -- prvt const.
kono
parents:
diff changeset
175 File_Access : in Permission_Type := Init_Permission; -- Grandparent
kono
parents:
diff changeset
176 -- prvt type,
kono
parents:
diff changeset
177 -- prvt const.
kono
parents:
diff changeset
178 File_Status : in File_Status_Type := Init_Status); -- Grandparent
kono
parents:
diff changeset
179 -- prvt type,
kono
parents:
diff changeset
180 -- prvt const.
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 end CA11011_0.CA11011_1.CA11011_2; -- Package OS.File_Manager.Internals
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 --=================================================================--
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 -- Package Body OS.File_Manager.Internals
kono
parents:
diff changeset
187 package body CA11011_0.CA11011_1.CA11011_2 is
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 procedure Create
kono
parents:
diff changeset
190 (Key : in File_Descriptor_Type;
kono
parents:
diff changeset
191 File_Name : in File_Name_Type := Get_File_Name;
kono
parents:
diff changeset
192 File_Mode : in File_Mode_Type := Init_Mode;
kono
parents:
diff changeset
193 File_Access : in Permission_Type := Init_Permission;
kono
parents:
diff changeset
194 File_Status : in File_Status_Type := Init_Status) is
kono
parents:
diff changeset
195 begin
kono
parents:
diff changeset
196 Private_File_Counter := Private_File_Counter + 1;
kono
parents:
diff changeset
197 File_Table(Key).Descriptor := Key; -- Grandparent object.
kono
parents:
diff changeset
198 File_Table(Key).Name := File_Name;
kono
parents:
diff changeset
199 File_Table(Key).Mode := File_Mode;
kono
parents:
diff changeset
200 File_Table(Key).Acct_Access := File_Access;
kono
parents:
diff changeset
201 File_Table(Key).Current_Status := File_Status;
kono
parents:
diff changeset
202 end Create;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 end CA11011_0.CA11011_1.CA11011_2; -- Package body OS.File_Manager.Internals
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 --=================================================================--
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 with CA11011_0.CA11011_1.CA11011_2; -- with Child OS.File_Manager.Internals
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 package body CA11011_0.CA11011_1 is -- Package body OS.File_Manager
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 package Internal renames CA11011_0.CA11011_1.CA11011_2;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 -- This subprogram utilizes a call to a subprogram contained in a private
kono
parents:
diff changeset
215 -- child to perform the actual processing.
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 procedure Create_File (File_Key : in File_Descriptor_Type) is
kono
parents:
diff changeset
218 begin
kono
parents:
diff changeset
219 Internal.Create (Key => File_Key); -- Other parameters are defaults,
kono
parents:
diff changeset
220 -- since they are of private types
kono
parents:
diff changeset
221 -- from the parent package.
kono
parents:
diff changeset
222 -- File_Descriptor_Type is private,
kono
parents:
diff changeset
223 -- but declared in visible part of
kono
parents:
diff changeset
224 -- parent spec.
kono
parents:
diff changeset
225 end Create_File;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 end CA11011_0.CA11011_1; -- Package body OS.File_Manager
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 --=================================================================--
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 with CA11011_0.CA11011_1; -- with public Child Package OS.File_Manager
kono
parents:
diff changeset
232 with Report;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 procedure CA11011 is
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 package OS renames CA11011_0;
kono
parents:
diff changeset
237 package File_Manager renames CA11011_0.CA11011_1;
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 Data_Base_File_Key : OS.File_Descriptor_Type := OS.First_File;
kono
parents:
diff changeset
240 TC_Status : Boolean := False;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 begin
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 -- This test indicates one approach to file management operations.
kono
parents:
diff changeset
245 -- It is not intended to demonstrate full functionality, but rather
kono
parents:
diff changeset
246 -- that the use of a private child package can provide a solution
kono
parents:
diff changeset
247 -- to a typical user situation.
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 Report.Test ("CA11011", "Check that a private child package can use " &
kono
parents:
diff changeset
250 "entities declared in the private part of the " &
kono
parents:
diff changeset
251 "parent unit of its parent unit");
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 OS.Verify_Initial_Conditions (Data_Base_File_Key, TC_Status);
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 if not TC_Status then
kono
parents:
diff changeset
256 Report.Failed ("Initial condition failure");
kono
parents:
diff changeset
257 end if;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 -- Perform file initializations.
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 File_Manager.Create_File (File_Key => Data_Base_File_Key);
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 TC_Status := OS.Final_Conditions_Valid (Data_Base_File_Key);
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 if not TC_Status then
kono
parents:
diff changeset
266 Report.Failed ("Bad status return from Create_File");
kono
parents:
diff changeset
267 end if;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 Report.Result;
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 end CA11011;