annotate gcc/testsuite/ada/acats/tests/cd/cdb0a01.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 -- CDB0A01.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 storage pool may be user_determined, and that storage
kono
parents:
diff changeset
28 -- is allocated by calling Allocate.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- Check that a storage.pool may be specified using 'Storage_Pool
kono
parents:
diff changeset
31 -- and that S'Storage_Pool denotes the storage pool of the type S.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION:
kono
parents:
diff changeset
34 -- The package System.Storage_Pools is exercised by two very similar
kono
parents:
diff changeset
35 -- packages which define a tree type and exercise it in a simple manner.
kono
parents:
diff changeset
36 -- One package uses a user defined pool. The other package uses a
kono
parents:
diff changeset
37 -- storage pool assigned by the implementation; Storage_Size is
kono
parents:
diff changeset
38 -- specified for this pool.
kono
parents:
diff changeset
39 -- The dispatching procedures Allocate and Deallocate are tested as an
kono
parents:
diff changeset
40 -- intentional side effect of the tree packages.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- For completeness, the actions of the tree packages are checked for
kono
parents:
diff changeset
43 -- correct operation.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- TEST FILES:
kono
parents:
diff changeset
46 -- The following files comprise this test:
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 -- FDB0A00.A (foundation code)
kono
parents:
diff changeset
49 -- CDB0A01.A
kono
parents:
diff changeset
50 --
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 -- CHANGE HISTORY:
kono
parents:
diff changeset
53 -- 02 JUN 95 SAIC Initial version
kono
parents:
diff changeset
54 -- 07 MAY 96 SAIC Removed ambiguity with CDB0A02
kono
parents:
diff changeset
55 -- 13 FEB 97 PWB.CTA Corrected lexically ordered string literal
kono
parents:
diff changeset
56 --!
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 ---------------------------------------------------------------- CDB0A01_1
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 ---------------------------------------------------------- FDB0A00.Pool1
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 package FDB0A00.Pool1 is
kono
parents:
diff changeset
63 User_Pool : Stack_Heap( 5_000 );
kono
parents:
diff changeset
64 end FDB0A00.Pool1;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 ---------------------------------------------------------- FDB0A00.Comparator
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 with System.Storage_Pools;
kono
parents:
diff changeset
69 package FDB0A00.Comparator is
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 function "="( A,B : System.Storage_Pools.Root_Storage_Pool'Class )
kono
parents:
diff changeset
72 return Boolean;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 end FDB0A00.Comparator;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 with TCTouch;
kono
parents:
diff changeset
79 package body FDB0A00.Comparator is
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 function "="( A,B : System.Storage_Pools.Root_Storage_Pool'Class )
kono
parents:
diff changeset
82 return Boolean is
kono
parents:
diff changeset
83 use type System.Address;
kono
parents:
diff changeset
84 begin
kono
parents:
diff changeset
85 return A'Address = B'Address;
kono
parents:
diff changeset
86 end "=";
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 end FDB0A00.Comparator;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 ---------------------------------------------------------------- CDB0A01_2
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 with FDB0A00.Pool1;
kono
parents:
diff changeset
93 package CDB0A01_2 is
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 type Cell;
kono
parents:
diff changeset
96 type User_Pool_Tree is access Cell;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 for User_Pool_Tree'Storage_Pool use FDB0A00.Pool1.User_Pool;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 type Cell is record
kono
parents:
diff changeset
101 Data : Character;
kono
parents:
diff changeset
102 Left,Right : User_Pool_Tree;
kono
parents:
diff changeset
103 end record;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 procedure Insert( Item: Character; On_Tree : in out User_Pool_Tree );
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Traverse( The_Tree : User_Pool_Tree );
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 procedure Defoliate( The_Tree : in out User_Pool_Tree );
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 end CDB0A01_2;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 with TCTouch;
kono
parents:
diff changeset
116 with Unchecked_Deallocation;
kono
parents:
diff changeset
117 package body CDB0A01_2 is
kono
parents:
diff changeset
118 procedure Deallocate is new Unchecked_Deallocation(Cell,User_Pool_Tree);
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- Sort: zeros on the left, ones on the right...
kono
parents:
diff changeset
121 procedure Insert( Item: Character; On_Tree : in out User_Pool_Tree ) is
kono
parents:
diff changeset
122 begin
kono
parents:
diff changeset
123 if On_Tree = null then
kono
parents:
diff changeset
124 On_Tree := new Cell'(Item,null,null);
kono
parents:
diff changeset
125 elsif Item > On_Tree.Data then
kono
parents:
diff changeset
126 Insert(Item,On_Tree.Right);
kono
parents:
diff changeset
127 else
kono
parents:
diff changeset
128 Insert(Item,On_Tree.Left);
kono
parents:
diff changeset
129 end if;
kono
parents:
diff changeset
130 end Insert;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure Traverse( The_Tree : User_Pool_Tree ) is
kono
parents:
diff changeset
133 begin
kono
parents:
diff changeset
134 if The_Tree = null then
kono
parents:
diff changeset
135 null; -- how very symmetrical
kono
parents:
diff changeset
136 else
kono
parents:
diff changeset
137 Traverse(The_Tree.Left);
kono
parents:
diff changeset
138 TCTouch.Touch(The_Tree.Data);
kono
parents:
diff changeset
139 Traverse(The_Tree.Right);
kono
parents:
diff changeset
140 end if;
kono
parents:
diff changeset
141 end Traverse;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 procedure Defoliate( The_Tree : in out User_Pool_Tree ) is
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 if The_Tree.Left /= null then
kono
parents:
diff changeset
147 Defoliate(The_Tree.Left);
kono
parents:
diff changeset
148 end if;
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 if The_Tree.Right /= null then
kono
parents:
diff changeset
151 Defoliate(The_Tree.Right);
kono
parents:
diff changeset
152 end if;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 Deallocate(The_Tree);
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 end Defoliate;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 end CDB0A01_2;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 ---------------------------------------------------------------- CDB0A01_3
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 with FDB0A00.Pool1;
kono
parents:
diff changeset
163 package CDB0A01_3 is
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 type Cell;
kono
parents:
diff changeset
166 type System_Pool_Tree is access Cell;
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 for System_Pool_Tree'Storage_Size use 2000;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 -- assumptions: Cell is <= 20 storage_units
kono
parents:
diff changeset
171 -- Tree building exercise requires O(15) cells
kono
parents:
diff changeset
172 -- 2000 > 20 * 15 by a generous margin
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 type Cell is record
kono
parents:
diff changeset
175 Data: Character;
kono
parents:
diff changeset
176 Left,Right : System_Pool_Tree;
kono
parents:
diff changeset
177 end record;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 procedure Insert( Item: Character; On_Tree : in out System_Pool_Tree );
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 procedure Traverse( The_Tree : System_Pool_Tree );
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 procedure Defoliate( The_Tree : in out System_Pool_Tree );
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 end CDB0A01_3;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 with TCTouch;
kono
parents:
diff changeset
190 with Unchecked_Deallocation;
kono
parents:
diff changeset
191 package body CDB0A01_3 is
kono
parents:
diff changeset
192 procedure Deallocate is new Unchecked_Deallocation(Cell,System_Pool_Tree);
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 -- Sort: zeros on the left, ones on the right...
kono
parents:
diff changeset
195 procedure Insert( Item: Character; On_Tree : in out System_Pool_Tree ) is
kono
parents:
diff changeset
196 begin
kono
parents:
diff changeset
197 if On_Tree = null then
kono
parents:
diff changeset
198 On_Tree := new Cell'(Item,null,null);
kono
parents:
diff changeset
199 elsif Item > On_Tree.Data then
kono
parents:
diff changeset
200 Insert(Item,On_Tree.Right);
kono
parents:
diff changeset
201 else
kono
parents:
diff changeset
202 Insert(Item,On_Tree.Left);
kono
parents:
diff changeset
203 end if;
kono
parents:
diff changeset
204 end Insert;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 procedure Traverse( The_Tree : System_Pool_Tree ) is
kono
parents:
diff changeset
207 begin
kono
parents:
diff changeset
208 if The_Tree = null then
kono
parents:
diff changeset
209 null; -- how very symmetrical
kono
parents:
diff changeset
210 else
kono
parents:
diff changeset
211 Traverse(The_Tree.Left);
kono
parents:
diff changeset
212 TCTouch.Touch(The_Tree.Data);
kono
parents:
diff changeset
213 Traverse(The_Tree.Right);
kono
parents:
diff changeset
214 end if;
kono
parents:
diff changeset
215 end Traverse;
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 procedure Defoliate( The_Tree : in out System_Pool_Tree ) is
kono
parents:
diff changeset
218 begin
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 if The_Tree.Left /= null then
kono
parents:
diff changeset
221 Defoliate(The_Tree.Left);
kono
parents:
diff changeset
222 end if;
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 if The_Tree.Right /= null then
kono
parents:
diff changeset
225 Defoliate(The_Tree.Right);
kono
parents:
diff changeset
226 end if;
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 Deallocate(The_Tree);
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 end Defoliate;
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 end CDB0A01_3;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 ------------------------------------------------------------------ CDB0A01
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 with Report;
kono
parents:
diff changeset
237 with TCTouch;
kono
parents:
diff changeset
238 with FDB0A00.Comparator;
kono
parents:
diff changeset
239 with FDB0A00.Pool1;
kono
parents:
diff changeset
240 with CDB0A01_2;
kono
parents:
diff changeset
241 with CDB0A01_3;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 procedure CDB0A01 is
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 Banyan : CDB0A01_2.User_Pool_Tree;
kono
parents:
diff changeset
246 Torrey : CDB0A01_3.System_Pool_Tree;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 use type CDB0A01_2.User_Pool_Tree;
kono
parents:
diff changeset
249 use type CDB0A01_3.System_Pool_Tree;
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 Countess : constant String := "Ada Augusta Lovelace";
kono
parents:
diff changeset
252 Cenosstu : constant String := " AALaaacdeeglostuuv";
kono
parents:
diff changeset
253 Insertion : constant String := "AAAAAAAAAAAAAAAAAAAA";
kono
parents:
diff changeset
254 Deallocation : constant String := "DDDDDDDDDDDDDDDDDDDD";
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 begin -- Main test procedure.
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 Report.Test ("CDB0A01", "Check that a storage pool may be " &
kono
parents:
diff changeset
259 "user_determined, and that storage is " &
kono
parents:
diff changeset
260 "allocated by calling Allocate. Check that " &
kono
parents:
diff changeset
261 "a storage.pool may be specified using " &
kono
parents:
diff changeset
262 "'Storage_Pool and that S'Storage_Pool denotes " &
kono
parents:
diff changeset
263 "the storage pool of the type S" );
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 -- Check that S'Storage_Pool denotes the storage pool for the type S.
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 TCTouch.Assert(
kono
parents:
diff changeset
268 FDB0A00.Comparator."="(FDB0A00.Pool1.User_Pool,
kono
parents:
diff changeset
269 CDB0A01_2.User_Pool_Tree'Storage_Pool ),
kono
parents:
diff changeset
270 "'Storage_Pool not correct for CDB0A01_2.User_Pool_Tree");
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 TCTouch.Assert_Not(
kono
parents:
diff changeset
273 FDB0A00.Comparator."="(FDB0A00.Pool1.User_Pool,
kono
parents:
diff changeset
274 CDB0A01_3.System_Pool_Tree'Storage_Pool ),
kono
parents:
diff changeset
275 "'Storage_Pool not correct for CDB0A01_3.System_Pool_Tree");
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 -- Check that storage is allocated by calling Allocate.
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 for Count in Countess'Range loop
kono
parents:
diff changeset
280 CDB0A01_2.Insert( Countess(Count), Banyan );
kono
parents:
diff changeset
281 end loop;
kono
parents:
diff changeset
282 TCTouch.Validate(Insertion, "Allocate calls via CDB0A01_2" );
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 for Count in Countess'Range loop
kono
parents:
diff changeset
285 CDB0A01_3.Insert( Countess(Count), Torrey );
kono
parents:
diff changeset
286 end loop;
kono
parents:
diff changeset
287 TCTouch.Validate("", "Allocate calls via CDB0A01_3" );
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 CDB0A01_2.Traverse(Banyan);
kono
parents:
diff changeset
290 TCTouch.Validate(Cenosstu, "Traversal of Banyan" );
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 CDB0A01_3.Traverse(Torrey);
kono
parents:
diff changeset
293 TCTouch.Validate(Cenosstu, "Traversal of Torrey" );
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 CDB0A01_2.Defoliate(Banyan);
kono
parents:
diff changeset
296 TCTouch.Validate(Deallocation, "Deforestation of Banyan" );
kono
parents:
diff changeset
297 TCTouch.Assert(Banyan = null, "Banyan Deallocation result not null");
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 CDB0A01_3.Defoliate(Torrey);
kono
parents:
diff changeset
300 TCTouch.Validate("", "Deforestation of Torrey" );
kono
parents:
diff changeset
301 TCTouch.Assert(Torrey = null, "Torrey Deallocation result not null");
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 Report.Result;
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 end CDB0A01;