1-- CA13003.A
2--
3--                             Grant of Unlimited Rights
4--
5--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7--     unlimited rights in the software and documentation contained herein.
8--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
9--     this public release, the Government intends to confer upon all
10--     recipients unlimited rights  equal to those held by the Government.
11--     These rights include rights to use, duplicate, release or disclose the
12--     released technical data and computer software in whole or in part, in
13--     any manner and for any purpose whatsoever, and to have or permit others
14--     to do so.
15--
16--                                    DISCLAIMER
17--
18--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23--     PARTICULAR PURPOSE OF SAID MATERIAL.
24--*
25--
26-- OBJECTIVE:
27--      Check that separate subunits which share an ancestor may have the
28--      same name if they have different fully qualified names.  Check
29--      the case of separate subunits of separate subunits.
30--      This test is a change in semantics from Ada 83 to Ada 9X.
31--
32-- TEST DESCRIPTION:
33--      Declare a package that provides file processing operations.  Declare
34--      one separate package to do the file processing, and another to do the
35--      auditing.  These packages contain similar functions declared in
36--      separate subunits.  Verify that the main program can call the
37--      separate subunits with the same name.
38--
39--
40-- CHANGE HISTORY:
41--      06 Dec 94   SAIC    ACVC 2.0
42--
43--!
44
45-- Simulates a file processing application.  The processing package opens
46-- files, reads files, does file processing, and generates reports.
47-- The auditing package opens files, read files, and generates reports.
48
49package CA13003_0 is
50
51   type File_ID is range 1 .. 100;
52   subtype File_Name is string (1 .. 10);
53
54   TC_Open_For_Process    : boolean := false;
55   TC_Open_For_Audit      : boolean := false;
56   TC_Report_From_Process : boolean := false;
57   TC_Report_From_Audit   : boolean := false;
58
59   type File_Rec is
60      record
61         Name : File_Name;
62         ID   : File_ID;
63      end record;
64
65   procedure Initialize_File_Rec (Name_In : in     File_Name;
66                                  ID_In   : in     File_ID;
67                                  File_In :    out File_Rec);
68
69   ----------------------------------------------------------------------
70
71   package CA13003_1 is    -- File processing
72
73      procedure CA13003_3;                             -- Open files
74      function CA13003_4 (ID_In : File_ID; File_In : File_Rec)
75        return File_Name;                              -- Process files
76      package CA13003_5 is                             -- Generate report
77         procedure Generate_Report;
78      end CA13003_5;
79
80   end CA13003_1;
81
82   ----------------------------------------------------------------------
83
84   package CA13003_2 is    -- File auditing
85
86      procedure CA13003_3;                             -- Open files
87      function CA13003_4 (ID_In : File_ID; File_In : File_Rec)
88        return File_Name;                              -- Process files
89      package CA13003_5 is                             -- Generate report
90         procedure Generate_Report;
91      end CA13003_5;
92
93   end CA13003_2;
94
95end CA13003_0;
96
97     --==================================================================--
98
99package body CA13003_0 is
100
101   procedure Initialize_File_Rec (Name_In : in     File_Name;
102                                  ID_In   : in     File_ID;
103                                  File_In :    out File_Rec) is
104   -- Not a real initialization.  Real application can use file
105   -- database to create the file record.
106   begin
107      File_In.Name := Name_In;
108      File_In.ID   := ID_In;
109   end Initialize_File_Rec;
110
111   package body CA13003_1 is separate;
112   package body CA13003_2 is separate;
113
114end CA13003_0;
115
116     --==================================================================--
117
118separate (CA13003_0)
119package body CA13003_1 is
120
121   procedure CA13003_3 is separate;                 -- Open files
122   function CA13003_4 (ID_In : File_ID; File_In : File_Rec)
123     return File_Name is separate;                  -- Process files
124   package body CA13003_5 is separate;              -- Generate report
125
126end CA13003_1;
127
128     --==================================================================--
129
130separate (CA13003_0.CA13003_1)
131procedure CA13003_3 is                              -- Open files
132begin
133   -- In real file processing application, open file from database, setup
134   -- data structure, etc.
135   TC_Open_For_Process := true;
136end CA13003_3;
137
138     --==================================================================--
139
140separate (CA13003_0.CA13003_1)
141function CA13003_4 (ID_In : File_ID;                -- Process files
142                    File_In : File_Rec) return File_Name is
143begin
144   -- In real file processing application, process files for more information.
145   return File_In.Name;
146end CA13003_4;
147
148     --==================================================================--
149
150separate (CA13003_0.CA13003_1)
151package body CA13003_5 is                           -- Generate report
152   procedure Generate_Report is
153   begin
154      -- In real file processing application, generate various report from the
155      -- file database.
156      TC_Report_From_Process := true;
157   end Generate_Report;
158
159end CA13003_5;
160
161     --==================================================================--
162
163separate (CA13003_0)
164package body CA13003_2 is
165
166   procedure CA13003_3 is separate;                 -- Open files
167   function CA13003_4 (ID_In : File_ID; File_In : File_Rec)
168     return File_Name is separate;                  -- Process files
169   package body CA13003_5 is separate;              -- Generate report
170
171end CA13003_2;
172
173     --==================================================================--
174
175separate (CA13003_0.CA13003_2)
176procedure CA13003_3 is                              -- Open files
177begin
178   TC_Open_For_Audit := true;
179end CA13003_3;
180
181     --==================================================================--
182
183separate (CA13003_0.CA13003_2)
184function CA13003_4 (ID_In : File_ID;
185                    File_In : File_Rec) return File_Name is
186begin
187   return File_In.Name;
188end CA13003_4;
189
190     --==================================================================--
191
192separate (CA13003_0.CA13003_2)
193package body CA13003_5 is                           -- Generate report
194   procedure Generate_Report is
195   begin
196      TC_Report_From_Audit := true;
197   end Generate_Report;
198
199end CA13003_5;
200
201     --==================================================================--
202
203with CA13003_0;
204with Report;
205
206procedure CA13003 is
207   First_File_Name  : CA13003_0.File_Name := "Joe Smith ";
208   First_File_Id    : CA13003_0.File_ID   := 11;
209   Second_File_Name : CA13003_0.File_Name := "John Schep";
210   Second_File_Id   : CA13003_0.File_ID   := 47;
211   Expected_Name    : CA13003_0.File_Name := "          ";
212   Student_File     : CA13003_0.File_Rec;
213
214   function Process_Input_Files (ID_In   : CA13003_0.File_ID;
215                                 File_In : CA13003_0.File_Rec) return
216     CA13003_0.File_Name renames CA13003_0.CA13003_1.CA13003_4;
217
218   function Process_Audit_Files (ID_In   : CA13003_0.File_ID;
219                                 File_In : CA13003_0.File_Rec) return
220     CA13003_0.File_Name renames CA13003_0.CA13003_2.CA13003_4;
221begin
222   Report.Test ("CA13003", "Check that separate subunits which share " &
223                "an ancestor may have the same name if they have " &
224                "different fully qualified names");
225
226   Student_File := (ID => First_File_Id, Name => First_File_Name);
227
228   -- Note that all subunits have the same simple name.
229   -- Generate report from file processing.
230   CA13003_0.CA13003_1.CA13003_3;
231   Expected_Name := Process_Input_Files (First_File_Id, Student_File);
232   CA13003_0.CA13003_1.CA13003_5.Generate_Report;
233
234   if not CA13003_0.TC_Open_For_Process or
235     not CA13003_0.TC_Report_From_Process or
236       Expected_Name /= First_File_Name then
237         Report.Failed ("Unexpected results in processing file");
238   end if;
239
240   CA13003_0.Initialize_File_Rec
241     (Second_File_Name, Second_File_Id, Student_File);
242
243   -- Generate report from file auditing.
244   CA13003_0.CA13003_2.CA13003_3;
245   Expected_Name := Process_Audit_Files (Second_File_Id, Student_File);
246   CA13003_0.CA13003_2.CA13003_5.Generate_Report;
247
248   if not CA13003_0.TC_Open_For_Audit or
249     not CA13003_0.TC_Report_From_Audit or
250       Expected_Name /= Second_File_Name then
251         Report.Failed ("Unexpected results in auditing file");
252   end if;
253
254   Report.Result;
255
256end CA13003;
257