annotate gcc/testsuite/ada/acats/tests/c7/c760002.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 -- C760002.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 assignment to an object of a (non-limited) controlled
kono
parents:
diff changeset
28 -- type causes the Adjust operation of the type to be called.
kono
parents:
diff changeset
29 -- Check that Adjust is called after copying the value of the
kono
parents:
diff changeset
30 -- source expression to the target object.
kono
parents:
diff changeset
31 --
kono
parents:
diff changeset
32 -- Check that Adjust is called for all controlled components when
kono
parents:
diff changeset
33 -- the containing object is assigned. (Test this for the cases
kono
parents:
diff changeset
34 -- where the type of the containing object is controlled and
kono
parents:
diff changeset
35 -- noncontrolled; test this for initialization as well as
kono
parents:
diff changeset
36 -- assignment statements.)
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- Check that for an object of a controlled type with controlled
kono
parents:
diff changeset
39 -- components, Adjust for each of the components is called before
kono
parents:
diff changeset
40 -- the containing object is adjusted.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- Check that an Adjust procedure for a Limited_Controlled type is
kono
parents:
diff changeset
43 -- not called by the implementation.
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- TEST DESCRIPTION:
kono
parents:
diff changeset
46 -- This test is loosely "derived" from C760001.
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 -- Visit Tags:
kono
parents:
diff changeset
49 -- D - Default value at declaration
kono
parents:
diff changeset
50 -- d - Default value at declaration, limited root
kono
parents:
diff changeset
51 -- I - initialize at root controlled
kono
parents:
diff changeset
52 -- i - initialize at root limited controlled
kono
parents:
diff changeset
53 -- A - adjust at root controlled
kono
parents:
diff changeset
54 -- X,Y,Z,x,y,z - used in test body
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 -- CHANGE HISTORY:
kono
parents:
diff changeset
58 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
59 -- 19 Dec 94 SAIC Correct test assertion logic for Sinister case
kono
parents:
diff changeset
60 --
kono
parents:
diff changeset
61 --!
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 ---------------------------------------------------------------- C760002_0
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 with Ada.Finalization;
kono
parents:
diff changeset
66 package C760002_0 is
kono
parents:
diff changeset
67 subtype Unique_ID is Natural;
kono
parents:
diff changeset
68 function Unique_Value return Unique_ID;
kono
parents:
diff changeset
69 -- increments each time it's called
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 function Most_Recent_Unique_Value return Unique_ID;
kono
parents:
diff changeset
72 -- returns the same value as the most recent call to Unique_Value
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 type Root is tagged record
kono
parents:
diff changeset
75 My_ID : Unique_ID := Unique_Value;
kono
parents:
diff changeset
76 Visit_Tag : Character := 'D'; -- Default
kono
parents:
diff changeset
77 end record;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 procedure Initialize( R: in out Root );
kono
parents:
diff changeset
80 procedure Adjust ( R: in out Root );
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 type Root_Controlled is new Ada.Finalization.Controlled with record
kono
parents:
diff changeset
83 My_ID : Unique_ID := Unique_Value;
kono
parents:
diff changeset
84 Visit_Tag : Character := 'D'; ---------------------------------------- D
kono
parents:
diff changeset
85 end record;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Initialize( R: in out Root_Controlled );
kono
parents:
diff changeset
88 procedure Adjust ( R: in out Root_Controlled );
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 type Root_Limited_Controlled is
kono
parents:
diff changeset
91 new Ada.Finalization.Limited_Controlled with record
kono
parents:
diff changeset
92 My_ID : Unique_ID := Unique_Value;
kono
parents:
diff changeset
93 Visit_Tag : Character := 'd'; ---------------------------------------- d
kono
parents:
diff changeset
94 end record;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 procedure Initialize( R: in out Root_Limited_Controlled );
kono
parents:
diff changeset
97 procedure Adjust ( R: in out Root_Limited_Controlled );
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 end C760002_0;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 with Report;
kono
parents:
diff changeset
102 package body C760002_0 is
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 Global_Unique_Counter : Unique_ID := 0;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 function Unique_Value return Unique_ID is
kono
parents:
diff changeset
107 begin
kono
parents:
diff changeset
108 Global_Unique_Counter := Global_Unique_Counter +1;
kono
parents:
diff changeset
109 return Global_Unique_Counter;
kono
parents:
diff changeset
110 end Unique_Value;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 function Most_Recent_Unique_Value return Unique_ID is
kono
parents:
diff changeset
113 begin
kono
parents:
diff changeset
114 return Global_Unique_Counter;
kono
parents:
diff changeset
115 end Most_Recent_Unique_Value;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure Initialize( R: in out Root ) is
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 Report.Failed("Initialize called for Non_Controlled type");
kono
parents:
diff changeset
120 end Initialize;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 procedure Adjust ( R: in out Root ) is
kono
parents:
diff changeset
123 begin
kono
parents:
diff changeset
124 Report.Failed("Adjust called for Non_Controlled type");
kono
parents:
diff changeset
125 end Adjust;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 procedure Initialize( R: in out Root_Controlled ) is
kono
parents:
diff changeset
128 begin
kono
parents:
diff changeset
129 R.Visit_Tag := 'I'; --------------------------------------------------- I
kono
parents:
diff changeset
130 end Initialize;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 procedure Adjust( R: in out Root_Controlled ) is
kono
parents:
diff changeset
133 begin
kono
parents:
diff changeset
134 R.Visit_Tag := 'A'; --------------------------------------------------- A
kono
parents:
diff changeset
135 end Adjust;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 procedure Initialize( R: in out Root_Limited_Controlled ) is
kono
parents:
diff changeset
138 begin
kono
parents:
diff changeset
139 R.Visit_Tag := 'i'; --------------------------------------------------- i
kono
parents:
diff changeset
140 end Initialize;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 procedure Adjust( R: in out Root_Limited_Controlled ) is
kono
parents:
diff changeset
143 begin
kono
parents:
diff changeset
144 Report.Failed("Adjust called for Limited_Controlled type");
kono
parents:
diff changeset
145 end Adjust;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 end C760002_0;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 ---------------------------------------------------------------- C760002_1
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 with Ada.Finalization;
kono
parents:
diff changeset
152 with C760002_0;
kono
parents:
diff changeset
153 package C760002_1 is
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 type Proc_ID is (None, Init, Adj, Fin);
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 type Test_Controlled is new C760002_0.Root_Controlled with record
kono
parents:
diff changeset
158 Last_Proc_Called: Proc_ID := None;
kono
parents:
diff changeset
159 end record;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 procedure Initialize( TC: in out Test_Controlled );
kono
parents:
diff changeset
162 procedure Adjust ( TC: in out Test_Controlled );
kono
parents:
diff changeset
163 procedure Finalize ( TC: in out Test_Controlled );
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 type Nested_Controlled is new C760002_0.Root_Controlled with record
kono
parents:
diff changeset
166 Nested : C760002_0.Root_Controlled;
kono
parents:
diff changeset
167 Last_Proc_Called: Proc_ID := None;
kono
parents:
diff changeset
168 end record;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 procedure Initialize( TC: in out Nested_Controlled );
kono
parents:
diff changeset
171 procedure Adjust ( TC: in out Nested_Controlled );
kono
parents:
diff changeset
172 procedure Finalize ( TC: in out Nested_Controlled );
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 type Test_Limited_Controlled is
kono
parents:
diff changeset
175 new C760002_0.Root_Limited_Controlled with record
kono
parents:
diff changeset
176 Last_Proc_Called: Proc_ID := None;
kono
parents:
diff changeset
177 end record;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 procedure Initialize( TC: in out Test_Limited_Controlled );
kono
parents:
diff changeset
180 procedure Adjust ( TC: in out Test_Limited_Controlled );
kono
parents:
diff changeset
181 procedure Finalize ( TC: in out Test_Limited_Controlled );
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 type Nested_Limited_Controlled is
kono
parents:
diff changeset
184 new C760002_0.Root_Limited_Controlled with record
kono
parents:
diff changeset
185 Nested : C760002_0.Root_Limited_Controlled;
kono
parents:
diff changeset
186 Last_Proc_Called: Proc_ID := None;
kono
parents:
diff changeset
187 end record;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 procedure Initialize( TC: in out Nested_Limited_Controlled );
kono
parents:
diff changeset
190 procedure Adjust ( TC: in out Nested_Limited_Controlled );
kono
parents:
diff changeset
191 procedure Finalize ( TC: in out Nested_Limited_Controlled );
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 end C760002_1;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 with Report;
kono
parents:
diff changeset
196 package body C760002_1 is
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 procedure Initialize( TC: in out Test_Controlled ) is
kono
parents:
diff changeset
199 begin
kono
parents:
diff changeset
200 TC.Last_Proc_Called := Init;
kono
parents:
diff changeset
201 C760002_0.Initialize(C760002_0.Root_Controlled(TC));
kono
parents:
diff changeset
202 end Initialize;
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 procedure Adjust ( TC: in out Test_Controlled ) is
kono
parents:
diff changeset
205 begin
kono
parents:
diff changeset
206 TC.Last_Proc_Called := Adj;
kono
parents:
diff changeset
207 C760002_0.Adjust(C760002_0.Root_Controlled(TC));
kono
parents:
diff changeset
208 end Adjust;
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 procedure Finalize ( TC: in out Test_Controlled ) is
kono
parents:
diff changeset
211 begin
kono
parents:
diff changeset
212 TC.Last_Proc_Called := Fin;
kono
parents:
diff changeset
213 end Finalize;
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 procedure Initialize( TC: in out Nested_Controlled ) is
kono
parents:
diff changeset
216 begin
kono
parents:
diff changeset
217 TC.Last_Proc_Called := Init;
kono
parents:
diff changeset
218 C760002_0.Initialize(C760002_0.Root_Controlled(TC));
kono
parents:
diff changeset
219 end Initialize;
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 procedure Adjust ( TC: in out Nested_Controlled ) is
kono
parents:
diff changeset
222 begin
kono
parents:
diff changeset
223 TC.Last_Proc_Called := Adj;
kono
parents:
diff changeset
224 C760002_0.Adjust(C760002_0.Root_Controlled(TC));
kono
parents:
diff changeset
225 end Adjust;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 procedure Finalize ( TC: in out Nested_Controlled ) is
kono
parents:
diff changeset
228 begin
kono
parents:
diff changeset
229 TC.Last_Proc_Called := Fin;
kono
parents:
diff changeset
230 end Finalize;
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 procedure Initialize( TC: in out Test_Limited_Controlled ) is
kono
parents:
diff changeset
233 begin
kono
parents:
diff changeset
234 TC.Last_Proc_Called := Init;
kono
parents:
diff changeset
235 C760002_0.Initialize(C760002_0.Root_Limited_Controlled(TC));
kono
parents:
diff changeset
236 end Initialize;
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 procedure Adjust ( TC: in out Test_Limited_Controlled ) is
kono
parents:
diff changeset
239 begin
kono
parents:
diff changeset
240 Report.Failed("Adjust called for Test_Limited_Controlled");
kono
parents:
diff changeset
241 end Adjust;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 procedure Finalize ( TC: in out Test_Limited_Controlled ) is
kono
parents:
diff changeset
244 begin
kono
parents:
diff changeset
245 TC.Last_Proc_Called := Fin;
kono
parents:
diff changeset
246 end Finalize;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 procedure Initialize( TC: in out Nested_Limited_Controlled ) is
kono
parents:
diff changeset
249 begin
kono
parents:
diff changeset
250 TC.Last_Proc_Called := Init;
kono
parents:
diff changeset
251 C760002_0.Initialize(C760002_0.Root_Limited_Controlled(TC));
kono
parents:
diff changeset
252 end Initialize;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 procedure Adjust ( TC: in out Nested_Limited_Controlled ) is
kono
parents:
diff changeset
255 begin
kono
parents:
diff changeset
256 Report.Failed("Adjust called for Nested_Limited_Controlled");
kono
parents:
diff changeset
257 end Adjust;
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 procedure Finalize ( TC: in out Nested_Limited_Controlled ) is
kono
parents:
diff changeset
260 begin
kono
parents:
diff changeset
261 TC.Last_Proc_Called := Fin;
kono
parents:
diff changeset
262 end Finalize;
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 end C760002_1;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 ---------------------------------------------------------------- C760002
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 with Report;
kono
parents:
diff changeset
269 with TCTouch;
kono
parents:
diff changeset
270 with C760002_0;
kono
parents:
diff changeset
271 with C760002_1;
kono
parents:
diff changeset
272 with Ada.Finalization;
kono
parents:
diff changeset
273 procedure C760002 is
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 use type C760002_1.Proc_ID;
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 -- in the first test, test the simple cases.
kono
parents:
diff changeset
278 -- Also check that assignment causes a call to Adjust for a controlled
kono
parents:
diff changeset
279 -- object. Check that assignment of a non-controlled object does not call
kono
parents:
diff changeset
280 -- an Adjust procedure.
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 procedure Check_Simple_Objects is
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 A,B : C760002_0.Root;
kono
parents:
diff changeset
285 S,T : C760002_1.Test_Controlled;
kono
parents:
diff changeset
286 Q : C760002_1.Test_Limited_Controlled; -- Adjust call shouldn't happen
kono
parents:
diff changeset
287 begin
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 S := T;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 TCTouch.Assert((S.Last_Proc_Called = C760002_1.Adj),
kono
parents:
diff changeset
292 "Adjust for simple object");
kono
parents:
diff changeset
293 TCTouch.Assert((S.My_ID = T.My_ID),
kono
parents:
diff changeset
294 "Assignment failed for simple object");
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 -- Check that adjust was called
kono
parents:
diff changeset
297 TCTouch.Assert((S.Visit_Tag = 'A'), "Adjust timing incorrect");
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 -- Check that Adjust has not been called
kono
parents:
diff changeset
300 TCTouch.Assert_Not((T.Visit_Tag = 'A'), "Adjust incorrectly called");
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 -- Check that Adjust does not get called
kono
parents:
diff changeset
303 A.My_ID := A.My_ID +1;
kono
parents:
diff changeset
304 B := A; -- see: Adjust: Report.Failed
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 end Check_Simple_Objects;
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 -- in the second test, test a more complex case, check that a controlled
kono
parents:
diff changeset
309 -- component of a controlled object gets processed correctly
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 procedure Check_Nested_Objects is
kono
parents:
diff changeset
312 NO1 : C760002_1.Nested_Controlled;
kono
parents:
diff changeset
313 NO2 : C760002_1.Nested_Controlled := NO1;
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 begin
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 -- NO2 should be flagged with adjust markers
kono
parents:
diff changeset
318 TCTouch.Assert((NO2.Last_Proc_Called = C760002_1.Adj),
kono
parents:
diff changeset
319 "Adjust not called for NO2 enclosure declaration");
kono
parents:
diff changeset
320 TCTouch.Assert((NO2.Nested.Visit_Tag = 'A'),
kono
parents:
diff changeset
321 "Adjust not called for NO2 enclosed declaration");
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 NO2.Visit_Tag := 'x';
kono
parents:
diff changeset
324 NO2.Nested.Visit_Tag := 'y';
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 NO1 := NO2;
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 -- NO1 should be flagged with adjust markers
kono
parents:
diff changeset
329 TCTouch.Assert((NO1.Visit_Tag = 'A'),
kono
parents:
diff changeset
330 "Adjust not called for NO1 enclosure declaration");
kono
parents:
diff changeset
331 TCTouch.Assert((NO1.Nested.Visit_Tag = 'A'),
kono
parents:
diff changeset
332 "Adjust not called for NO1 enclosed declaration");
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 end Check_Nested_Objects;
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 procedure Check_Array_Case is
kono
parents:
diff changeset
337 type Array_Simple is array(1..4) of C760002_1.Test_Controlled;
kono
parents:
diff changeset
338 type Array_Nested is array(1..4) of C760002_1.Nested_Controlled;
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 Left,Right : Array_Simple;
kono
parents:
diff changeset
341 Overlap : Array_Simple := Left;
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 Sinister,Dexter : Array_Nested;
kono
parents:
diff changeset
344 Underlap : Array_Nested := Sinister;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 Now : Natural;
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 begin
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 -- get a current unique value since initializations
kono
parents:
diff changeset
351 Now := C760002_0.Unique_Value;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 -- check results of declarations
kono
parents:
diff changeset
354 for N in 1..4 loop
kono
parents:
diff changeset
355 TCTouch.Assert(Left(N).My_Id < Now,
kono
parents:
diff changeset
356 "Initialize for array initial value");
kono
parents:
diff changeset
357 TCTouch.Assert(Overlap(N).My_Id < Now,
kono
parents:
diff changeset
358 "Adjust for nested array (outer) initial value");
kono
parents:
diff changeset
359 TCTouch.Assert(Sinister(N).Nested.My_Id < Now,
kono
parents:
diff changeset
360 "Initialize for nested array (inner) initial value");
kono
parents:
diff changeset
361 TCTouch.Assert(Sinister(N).My_Id < Sinister(N).Nested.My_Id,
kono
parents:
diff changeset
362 "Initialize for enclosure should be after enclosed");
kono
parents:
diff changeset
363 TCTouch.Assert(Overlap(N).Visit_Tag = 'A',"Adjust at declaration");
kono
parents:
diff changeset
364 TCTouch.Assert(Underlap(N).Nested.Visit_Tag = 'A',
kono
parents:
diff changeset
365 "Adjust at declaration, nested object");
kono
parents:
diff changeset
366 end loop;
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 -- set visit tags
kono
parents:
diff changeset
369 for O in 1..4 loop
kono
parents:
diff changeset
370 Overlap(O).Visit_Tag := 'X';
kono
parents:
diff changeset
371 Underlap(O).Visit_Tag := 'Y';
kono
parents:
diff changeset
372 Underlap(O).Nested.Visit_Tag := 'y';
kono
parents:
diff changeset
373 end loop;
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 -- check that overlapping assignments don't cause odd grief
kono
parents:
diff changeset
376 Overlap(1..3) := Overlap(2..4);
kono
parents:
diff changeset
377 Underlap(2..4) := Underlap(1..3);
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 for M in 2..3 loop
kono
parents:
diff changeset
380 TCTouch.Assert(Overlap(M).Last_Proc_Called = C760002_1.Adj,
kono
parents:
diff changeset
381 "Adjust for overlap");
kono
parents:
diff changeset
382 TCTouch.Assert(Overlap(M).Visit_Tag = 'A',
kono
parents:
diff changeset
383 "Adjust for overlap ID");
kono
parents:
diff changeset
384 TCTouch.Assert(Underlap(M).Last_Proc_Called = C760002_1.Adj,
kono
parents:
diff changeset
385 "Adjust for Underlap");
kono
parents:
diff changeset
386 TCTouch.Assert(Underlap(M).Nested.Visit_Tag = 'A',
kono
parents:
diff changeset
387 "Adjust for Underlaps nested ID");
kono
parents:
diff changeset
388 end loop;
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 end Check_Array_Case;
kono
parents:
diff changeset
391
kono
parents:
diff changeset
392 procedure Check_Access_Case is
kono
parents:
diff changeset
393 type TC_Ref is access C760002_1.Test_Controlled;
kono
parents:
diff changeset
394 type NC_Ref is access C760002_1.Nested_Controlled;
kono
parents:
diff changeset
395 type TL_Ref is access C760002_1.Test_Limited_Controlled;
kono
parents:
diff changeset
396 type NL_Ref is access C760002_1.Nested_Limited_Controlled;
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 A,B : TC_Ref;
kono
parents:
diff changeset
399 C,D : NC_Ref;
kono
parents:
diff changeset
400 E : TL_Ref;
kono
parents:
diff changeset
401 F : NL_Ref;
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 begin
kono
parents:
diff changeset
404
kono
parents:
diff changeset
405 A := new C760002_1.Test_Controlled;
kono
parents:
diff changeset
406 B := new C760002_1.Test_Controlled'( A.all );
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 C := new C760002_1.Nested_Controlled;
kono
parents:
diff changeset
409 D := new C760002_1.Nested_Controlled'( C.all );
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 E := new C760002_1.Test_Limited_Controlled;
kono
parents:
diff changeset
412 F := new C760002_1.Nested_Limited_Controlled;
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 TCTouch.Assert(A.Visit_Tag = 'I',"TC Allocation");
kono
parents:
diff changeset
415 TCTouch.Assert(B.Visit_Tag = 'A',"TC Allocation, with value");
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 TCTouch.Assert(C.Visit_Tag = 'I',"NC Allocation");
kono
parents:
diff changeset
418 TCTouch.Assert(C.Nested.Visit_Tag = 'I',"NC Allocation, Nested");
kono
parents:
diff changeset
419 TCTouch.Assert(D.Visit_Tag = 'A',"NC Allocation, with value");
kono
parents:
diff changeset
420 TCTouch.Assert(D.Nested.Visit_Tag = 'A',
kono
parents:
diff changeset
421 "NC Allocation, Nested, with value");
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 TCTouch.Assert(E.Visit_Tag = 'i',"TL Allocation");
kono
parents:
diff changeset
424 TCTouch.Assert(F.Visit_Tag = 'i',"NL Allocation");
kono
parents:
diff changeset
425
kono
parents:
diff changeset
426 A.all := B.all;
kono
parents:
diff changeset
427 C.all := D.all;
kono
parents:
diff changeset
428
kono
parents:
diff changeset
429 TCTouch.Assert(A.Visit_Tag = 'A',"TC Assignment");
kono
parents:
diff changeset
430 TCTouch.Assert(C.Visit_Tag = 'A',"NC Assignment");
kono
parents:
diff changeset
431 TCTouch.Assert(C.Nested.Visit_Tag = 'A',"NC Assignment, Nested");
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433 end Check_Access_Case;
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 procedure Check_Access_Limited_Array_Case is
kono
parents:
diff changeset
436 type Array_Simple is array(1..4) of C760002_1.Test_Limited_Controlled;
kono
parents:
diff changeset
437 type AS_Ref is access Array_Simple;
kono
parents:
diff changeset
438 type Array_Nested is array(1..4) of C760002_1.Nested_Limited_Controlled;
kono
parents:
diff changeset
439 type AN_Ref is access Array_Nested;
kono
parents:
diff changeset
440
kono
parents:
diff changeset
441 Simple_Array_Limited : AS_Ref;
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 Nested_Array_Limited : AN_Ref;
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 begin
kono
parents:
diff changeset
446
kono
parents:
diff changeset
447 Simple_Array_Limited := new Array_Simple;
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 Nested_Array_Limited := new Array_Nested;
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 for N in 1..4 loop
kono
parents:
diff changeset
452 TCTouch.Assert(Simple_Array_Limited(N).Last_Proc_Called
kono
parents:
diff changeset
453 = C760002_1.Init,
kono
parents:
diff changeset
454 "Initialize for array initial value");
kono
parents:
diff changeset
455 TCTouch.Assert(Nested_Array_Limited(N).Last_Proc_Called
kono
parents:
diff changeset
456 = C760002_1.Init,
kono
parents:
diff changeset
457 "Initialize for nested array (outer) initial value");
kono
parents:
diff changeset
458 TCTouch.Assert(Nested_Array_Limited(N).Nested.Visit_Tag = 'i',
kono
parents:
diff changeset
459 "Initialize for nested array (inner) initial value");
kono
parents:
diff changeset
460 end loop;
kono
parents:
diff changeset
461 end Check_Access_Limited_Array_Case;
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463 begin -- Main test procedure.
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 Report.Test ("C760002", "Check that assignment causes the Adjust " &
kono
parents:
diff changeset
466 "operation of the type to be called. Check " &
kono
parents:
diff changeset
467 "that Adjust is called after copying the " &
kono
parents:
diff changeset
468 "value of the source expression to the target " &
kono
parents:
diff changeset
469 "object. Check that Adjust is called for all " &
kono
parents:
diff changeset
470 "controlled components when the containing " &
kono
parents:
diff changeset
471 "object is assigned. Check that Adjust is " &
kono
parents:
diff changeset
472 "called for components before the containing " &
kono
parents:
diff changeset
473 "object is adjusted. Check that Adjust is not " &
kono
parents:
diff changeset
474 "called for a Limited_Controlled type by the " &
kono
parents:
diff changeset
475 "implementation" );
kono
parents:
diff changeset
476
kono
parents:
diff changeset
477 Check_Simple_Objects;
kono
parents:
diff changeset
478
kono
parents:
diff changeset
479 Check_Nested_Objects;
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 Check_Array_Case;
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 Check_Access_Case;
kono
parents:
diff changeset
484
kono
parents:
diff changeset
485 Check_Access_Limited_Array_Case;
kono
parents:
diff changeset
486
kono
parents:
diff changeset
487 Report.Result;
kono
parents:
diff changeset
488
kono
parents:
diff changeset
489 end C760002;