annotate gcc/testsuite/ada/acats/tests/ca/ca11009.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 -- CA11009.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 -- visible 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 types and objects used by the
kono
parents:
diff changeset
32 -- system. Declare a public child package that provides a visible
kono
parents:
diff changeset
33 -- 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 structure for
kono
parents:
diff changeset
43 -- file 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 -- 15 Apr 96 SAIC ACVC 2.1: Added pragma Elaborate_body.
kono
parents:
diff changeset
49 --
kono
parents:
diff changeset
50 --!
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 package CA11009_0 is -- Package OS.
kono
parents:
diff changeset
53 pragma Elaborate_Body (CA11009_0);
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 type File_Descriptor_Type is new Integer;
kono
parents:
diff changeset
56 type File_Name_Type is new String (1 .. 11);
kono
parents:
diff changeset
57 type Permission_Type is (None, User, System, Bypass);
kono
parents:
diff changeset
58 type File_Mode_Type is (Read_Only, Write_Only, Read_Write);
kono
parents:
diff changeset
59 type File_Status_Type is (Open, Closed);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 Default_Descriptor : constant File_Descriptor_Type := 0;
kono
parents:
diff changeset
62 Default_Permission : constant Permission_Type := None;
kono
parents:
diff changeset
63 Default_Mode : constant File_Mode_Type := Read_Only;
kono
parents:
diff changeset
64 Default_Status : constant File_Status_Type := Closed;
kono
parents:
diff changeset
65 Default_Filename : constant File_Name_Type := " ";
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 Max_Files : constant File_Descriptor_Type := 10;
kono
parents:
diff changeset
68 An_Ada_File_Name : constant File_Name_Type := "AdaFileName";
kono
parents:
diff changeset
69 File_Counter : Integer := 0;
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 type File_Type is tagged
kono
parents:
diff changeset
72 record
kono
parents:
diff changeset
73 Descriptor : File_Descriptor_Type := Default_Descriptor;
kono
parents:
diff changeset
74 Name : File_Name_Type := Default_Filename;
kono
parents:
diff changeset
75 Acct_Access : Permission_Type := Default_Permission;
kono
parents:
diff changeset
76 Mode : File_Mode_Type := Default_Mode;
kono
parents:
diff changeset
77 Current_Status : File_Status_Type := Default_Status;
kono
parents:
diff changeset
78 end record;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 type File_Array_Type is array (1 .. Max_Files) of File_Type;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 File_Table : File_Array_Type;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 --
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function Get_File_Name return File_Name_Type;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 end CA11009_0; -- Package OS.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 --=================================================================--
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 package body CA11009_0 is -- Package body OS.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 function Get_File_Name return File_Name_Type is
kono
parents:
diff changeset
95 begin
kono
parents:
diff changeset
96 return (An_Ada_File_Name); -- Processing would be replace by a user
kono
parents:
diff changeset
97 -- prompt in a functioning system.
kono
parents:
diff changeset
98 end Get_File_Name;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 end CA11009_0; -- Package body OS.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 --=================================================================--
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 package CA11009_0.CA11009_1 is -- Child Package OS.File_Manager
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- This package simulates a visible interface for the Operating System.
kono
parents:
diff changeset
107 -- The actual processing performed by this routine is encapsulated
kono
parents:
diff changeset
108 -- in the routines of private child package Internals, which is "withed"
kono
parents:
diff changeset
109 -- by the body of this package.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Create_File (Mode : in File_Mode_Type;
kono
parents:
diff changeset
112 File_Key : out File_Descriptor_Type);
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 end CA11009_0.CA11009_1; -- Child Package OS.File_Manager
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 --=================================================================--
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 -- Subprogram that performs the actual file operation is contained in a
kono
parents:
diff changeset
119 -- private package so that it is not accessible to any client, and can be
kono
parents:
diff changeset
120 -- modified/extended without requiring recompilation of the clients of the
kono
parents:
diff changeset
121 -- parent (since this package is "withed" by the parent body only.)
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 -- Grandchild Package OS.File_Manager.Internals
kono
parents:
diff changeset
125 private package CA11009_0.CA11009_1.CA11009_2 is
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 Initial_Permission : constant Permission_Type := User; -- Grandparent
kono
parents:
diff changeset
128 Initial_Status : constant File_Status_Type := Open; -- literals.
kono
parents:
diff changeset
129 Initial_Filename : constant File_Name_Type := -- Grandparent type.
kono
parents:
diff changeset
130 Get_File_Name; -- Grandparent function.
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 function Create (Mode : File_Mode_Type)
kono
parents:
diff changeset
133 return File_Descriptor_Type; -- Grandparent type.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 end CA11009_0.CA11009_1.CA11009_2;
kono
parents:
diff changeset
136 -- Grandchild Package OS.File_Manager.Internals
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 --=================================================================--
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 -- Grandchild Package body OS.File_Manager.Internals
kono
parents:
diff changeset
141 package body CA11009_0.CA11009_1.CA11009_2 is
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 function Next_Available_File return File_Descriptor_Type is
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 File_Counter := File_Counter + 1; -- Grandparent object.
kono
parents:
diff changeset
146 return (File_Descriptor_Type(File_Counter));
kono
parents:
diff changeset
147 end Next_Available_File;
kono
parents:
diff changeset
148 -------------------------------------------------------------------------
kono
parents:
diff changeset
149 function Create (Mode : File_Mode_Type) -- Grandparent literal.
kono
parents:
diff changeset
150 return File_Descriptor_Type is
kono
parents:
diff changeset
151 Number : File_Descriptor_Type; -- Grandparent type.
kono
parents:
diff changeset
152 begin
kono
parents:
diff changeset
153 Number := Next_Available_File;
kono
parents:
diff changeset
154 File_Table(Number).Descriptor := Number; -- Grandparent object.
kono
parents:
diff changeset
155 File_Table(Number).Name := Initial_Filename;
kono
parents:
diff changeset
156 File_Table(Number).Mode := Mode; -- Parameter.
kono
parents:
diff changeset
157 File_Table(Number).Acct_Access := Initial_Permission;
kono
parents:
diff changeset
158 File_Table(Number).Current_Status := Initial_Status;
kono
parents:
diff changeset
159 return (Number);
kono
parents:
diff changeset
160 end Create;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 end CA11009_0.CA11009_1.CA11009_2;
kono
parents:
diff changeset
163 -- Grandchild Package body OS.File_Manager.Internals
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 --=================================================================--
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 -- "With" of a child package
kono
parents:
diff changeset
168 -- by the parent body.
kono
parents:
diff changeset
169 with CA11009_0.CA11009_1.CA11009_2; -- Grandchild OS.File_Manager.Internals
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 package body CA11009_0.CA11009_1 is -- Child Package body OS.File_Manager
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 package Internal renames CA11009_0.CA11009_1.CA11009_2;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 -- These subprograms utilize calls to subprograms contained in a private
kono
parents:
diff changeset
176 -- sibling to perform the actual processing.
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 procedure Create_File (Mode : in File_Mode_Type;
kono
parents:
diff changeset
179 File_Key : out File_Descriptor_Type) is
kono
parents:
diff changeset
180 begin
kono
parents:
diff changeset
181 File_Key := Internal.Create (Mode);
kono
parents:
diff changeset
182 end Create_File;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 end CA11009_0.CA11009_1; -- Child Package body OS.File_Manager
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 --=================================================================--
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 with CA11009_0.CA11009_1; -- with Child Package OS.File_Manager
kono
parents:
diff changeset
189 with Report;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 procedure CA11009 is
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 package OS renames CA11009_0;
kono
parents:
diff changeset
194 use OS;
kono
parents:
diff changeset
195 package File_Manager renames CA11009_0.CA11009_1;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 Data_Base_File_Key : File_Descriptor_Type := Default_Descriptor;
kono
parents:
diff changeset
198 New_Mode : File_Mode_Type := Read_Write;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 begin
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 -- This test indicates one approach to file management.
kono
parents:
diff changeset
203 -- It is not intended to demonstrate full functionality, but rather
kono
parents:
diff changeset
204 -- that the use of a private child package could provide a solution
kono
parents:
diff changeset
205 -- to this type of situation.
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 Report.Test ("CA11009", "Check that a private child package can use " &
kono
parents:
diff changeset
208 "entities declared in the visible part of the " &
kono
parents:
diff changeset
209 "parent unit of its parent unit");
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 -- Check initial conditions of the first entry in the file table.
kono
parents:
diff changeset
212 -- These are all default values provided in the declaration of the
kono
parents:
diff changeset
213 -- type File_Type.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 if (not (Data_Base_File_Key = Default_Descriptor)) and then
kono
parents:
diff changeset
216 (((not (File_Table(1).Name = Default_Filename)) or
kono
parents:
diff changeset
217 (File_Table(1).Descriptor /= Default_Descriptor)) or else
kono
parents:
diff changeset
218 ((File_Table(1).Acct_Access /= Default_Permission) or
kono
parents:
diff changeset
219 (not (File_Table(1).Mode = Default_Mode)) or
kono
parents:
diff changeset
220 (File_Table(1).Current_Status /= Default_Status)))
kono
parents:
diff changeset
221 then
kono
parents:
diff changeset
222 Report.Failed ("Initial condition failure");
kono
parents:
diff changeset
223 end if;
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 -- Create/initialize file using the capability provided by the visible
kono
parents:
diff changeset
226 -- interface to the operating system, OS.File_Manager. The actual
kono
parents:
diff changeset
227 -- processing routine is contained in the private grandchild package
kono
parents:
diff changeset
228 -- Internals, which utilize the components from the grandparent package.
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 File_Manager.Create_File (New_Mode, Data_Base_File_Key);
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 -- Verify that the initial conditions of the file table component have
kono
parents:
diff changeset
233 -- been properly modified by the initialization function.
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 if not ((File_Table(1).Descriptor = Data_Base_File_Key) and then
kono
parents:
diff changeset
236 (File_Table(1).Name = An_Ada_File_Name) and then
kono
parents:
diff changeset
237 (File_Table(1).Acct_Access = User) and then
kono
parents:
diff changeset
238 not ((File_Table(1).Mode = Default_Mode) or else
kono
parents:
diff changeset
239 (File_Table(1).Current_Status = Default_Status)))
kono
parents:
diff changeset
240 then
kono
parents:
diff changeset
241 Report.Failed ("File creation failure");
kono
parents:
diff changeset
242 end if;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 Report.Result;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 end CA11009;