annotate gcc/testsuite/ada/acats/tests/c3/c340001.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 -- C340001.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 user-defined equality operators are inherited by a
kono
parents:
diff changeset
28 -- derived type except when the derived type is a nonlimited record
kono
parents:
diff changeset
29 -- extension. In the latter case, ensure that the primitive
kono
parents:
diff changeset
30 -- equality operation of the record extension compares any extended
kono
parents:
diff changeset
31 -- components according to the predefined equality operators of the
kono
parents:
diff changeset
32 -- component types. Also check that the parent portion of the extended
kono
parents:
diff changeset
33 -- type is compared using the user-defined equality operation of the
kono
parents:
diff changeset
34 -- parent type.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- TEST DESCRIPTION:
kono
parents:
diff changeset
37 -- Declares a nonlimited tagged record and a limited tagged record
kono
parents:
diff changeset
38 -- type, each in a separate package. A user-defined "=" operation is
kono
parents:
diff changeset
39 -- defined for each type. Each type is extended with one new record
kono
parents:
diff changeset
40 -- component added.
kono
parents:
diff changeset
41 --
kono
parents:
diff changeset
42 -- Objects are declared for each parent and extended types and are
kono
parents:
diff changeset
43 -- assigned values. For the limited type, modifier operations defined
kono
parents:
diff changeset
44 -- in the package are used to assign values.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- To verify the use of the user-defined "=", values are assigned so
kono
parents:
diff changeset
47 -- that predefined equality will return the opposite result if called.
kono
parents:
diff changeset
48 -- Similarly, values are assigned to the extended type objects so that
kono
parents:
diff changeset
49 -- one comparison will verify that the inherited components from the
kono
parents:
diff changeset
50 -- parent are compared using the user-defined equality operation.
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 -- A second comparison sets the values of the inherited components to
kono
parents:
diff changeset
53 -- be the same so that equality based on the extended component may be
kono
parents:
diff changeset
54 -- verified. For the nonlimited type, the test for equality should
kono
parents:
diff changeset
55 -- fail, as the "=" defined for this type should include testing
kono
parents:
diff changeset
56 -- equality of the extended component. For the limited type, "=" of the
kono
parents:
diff changeset
57 -- parent should be inherited as-is, so the test for equality should
kono
parents:
diff changeset
58 -- succeed even though the records differ in the extended component.
kono
parents:
diff changeset
59 --
kono
parents:
diff changeset
60 -- A third package declares a discriminated tagged record. Equality
kono
parents:
diff changeset
61 -- is user-defined and ignores the discriminant value. A type
kono
parents:
diff changeset
62 -- extension is declared which also contains a discriminant. Since
kono
parents:
diff changeset
63 -- an inherited discriminant may not be referenced other than in a
kono
parents:
diff changeset
64 -- "new" discriminant, the type extension is also discriminated. The
kono
parents:
diff changeset
65 -- discriminant is used as the constraint for the parent type.
kono
parents:
diff changeset
66 --
kono
parents:
diff changeset
67 -- A variant part is declared in the type extension based on the new
kono
parents:
diff changeset
68 -- discriminant. Comparisons are made to confirm that the user-defined
kono
parents:
diff changeset
69 -- equality operator is used to compare values of the type extension.
kono
parents:
diff changeset
70 -- Two record objects are given values so that user-defined equality
kono
parents:
diff changeset
71 -- for the parent portion of the record succeeds, but the variant
kono
parents:
diff changeset
72 -- parts in the type extended object differ. These objects are checked
kono
parents:
diff changeset
73 -- to ensure that they are not equal.
kono
parents:
diff changeset
74 --
kono
parents:
diff changeset
75 --
kono
parents:
diff changeset
76 -- CHANGE HISTORY:
kono
parents:
diff changeset
77 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
78 -- 19 Dec 94 SAIC Removed RM references from objective text.
kono
parents:
diff changeset
79 --
kono
parents:
diff changeset
80 --!
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 with Ada.Calendar;
kono
parents:
diff changeset
83 package C340001_0 is
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 type DB_Record is tagged record
kono
parents:
diff changeset
86 Key : Natural range 1 .. 9999;
kono
parents:
diff changeset
87 Data : String (1..10);
kono
parents:
diff changeset
88 end record;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function "=" (L, R : in DB_Record) return Boolean;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 type Dated_Record is new DB_Record with record
kono
parents:
diff changeset
93 Retrieval_Time : Ada.Calendar.Time;
kono
parents:
diff changeset
94 end record;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 end C340001_0;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 package body C340001_0 is
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 function "=" (L, R : in DB_Record) return Boolean is
kono
parents:
diff changeset
101 -- Key is ignored in determining equality of records
kono
parents:
diff changeset
102 begin
kono
parents:
diff changeset
103 return L.Data = R.Data;
kono
parents:
diff changeset
104 end "=";
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 end C340001_0;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 package C340001_1 is
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 type List_Contents is array (1..10) of Integer;
kono
parents:
diff changeset
111 type List is tagged limited record
kono
parents:
diff changeset
112 Length : Natural range 0..10 := 0;
kono
parents:
diff changeset
113 Contents : List_Contents := (others => 0);
kono
parents:
diff changeset
114 end record;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 procedure Add_To (L : in out List; New_Value : in Integer);
kono
parents:
diff changeset
117 procedure Remove_From (L : in out List);
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 function "=" (L, R : in List) return Boolean;
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 subtype Revision_Mark is Character range 'A' .. 'Z';
kono
parents:
diff changeset
122 type Revisable_List is new List with record
kono
parents:
diff changeset
123 Revision : Revision_Mark := 'A';
kono
parents:
diff changeset
124 end record;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Revise (L : in out Revisable_List);
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 end C340001_1;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 package body C340001_1 is
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 -- Note: This is not a complete abstraction of a list. Exceptions
kono
parents:
diff changeset
133 -- are not defined and boundary checks are not made.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 procedure Add_To (L : in out List; New_Value : in Integer) is
kono
parents:
diff changeset
136 begin
kono
parents:
diff changeset
137 L.Length := L.Length + 1;
kono
parents:
diff changeset
138 L.Contents (L.Length) := New_Value;
kono
parents:
diff changeset
139 end Add_To;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 procedure Remove_From (L : in out List) is
kono
parents:
diff changeset
142 -- The list length is decremented. "Old" values are left in the
kono
parents:
diff changeset
143 -- array. They are overwritten when a new value is added.
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 L.Length := L.Length - 1;
kono
parents:
diff changeset
146 end Remove_From;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 function "=" (L, R : in List) return Boolean is
kono
parents:
diff changeset
149 -- Two lists are equal if they are the same length and
kono
parents:
diff changeset
150 -- the component values within that length are the same.
kono
parents:
diff changeset
151 -- Values stored past the end of the list are ignored.
kono
parents:
diff changeset
152 begin
kono
parents:
diff changeset
153 return L.Length = R.Length
kono
parents:
diff changeset
154 and then L.Contents (1..L.Length) = R.Contents (1..R.Length);
kono
parents:
diff changeset
155 end "=";
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 procedure Revise (L : in out Revisable_List) is
kono
parents:
diff changeset
158 begin
kono
parents:
diff changeset
159 L.Revision := Character'Succ (L.Revision);
kono
parents:
diff changeset
160 end Revise;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 end C340001_1;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 package C340001_2 is
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 type Media is (Paper, Electronic);
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 type Transaction (Medium : Media) is tagged record
kono
parents:
diff changeset
169 ID : Natural range 1000 .. 9999;
kono
parents:
diff changeset
170 end record;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 function "=" (L, R : in Transaction) return Boolean;
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 type Authorization (Kind : Media) is new Transaction (Medium => Kind)
kono
parents:
diff changeset
175 with record
kono
parents:
diff changeset
176 case Kind is
kono
parents:
diff changeset
177 when Paper =>
kono
parents:
diff changeset
178 Signature_On_File : Boolean;
kono
parents:
diff changeset
179 when Electronic =>
kono
parents:
diff changeset
180 Paper_Backup : Boolean; -- to retain opposing value
kono
parents:
diff changeset
181 end case;
kono
parents:
diff changeset
182 end record;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 end C340001_2;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 package body C340001_2 is
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 function "=" (L, R : in Transaction) return Boolean is
kono
parents:
diff changeset
189 -- There may be electronic and paper copies of the same transaction.
kono
parents:
diff changeset
190 -- The ID uniquely identifies a transaction. The medium (stored in
kono
parents:
diff changeset
191 -- the discriminant) is ignored.
kono
parents:
diff changeset
192 begin
kono
parents:
diff changeset
193 return L.ID = R.ID;
kono
parents:
diff changeset
194 end "=";
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 end C340001_2;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 with C340001_0; -- nonlimited tagged record declarations
kono
parents:
diff changeset
200 with C340001_1; -- limited tagged record declarations
kono
parents:
diff changeset
201 with C340001_2; -- tagged variant declarations
kono
parents:
diff changeset
202 with Ada.Calendar;
kono
parents:
diff changeset
203 with Report;
kono
parents:
diff changeset
204 procedure C340001 is
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 DB_Rec1 : C340001_0.DB_Record := (Key => 1,
kono
parents:
diff changeset
207 Data => "aaaaaaaaaa");
kono
parents:
diff changeset
208 DB_Rec2 : C340001_0.DB_Record := (Key => 55,
kono
parents:
diff changeset
209 Data => "aaaaaaaaaa");
kono
parents:
diff changeset
210 -- DB_Rec1 = DB_Rec2 using user-defined equality
kono
parents:
diff changeset
211 -- DB_Rec1 /= DB_Rec2 using predefined equality
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 Some_Time : Ada.Calendar.Time :=
kono
parents:
diff changeset
214 Ada.Calendar.Time_Of (Month => 9, Day => 16, Year => 1993);
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 Another_Time : Ada.Calendar.Time :=
kono
parents:
diff changeset
217 Ada.Calendar.Time_Of (Month => 9, Day => 19, Year => 1993);
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 Dated_Rec1 : C340001_0.Dated_Record := (Key => 2,
kono
parents:
diff changeset
220 Data => "aaaaaaaaaa",
kono
parents:
diff changeset
221 Retrieval_Time => Some_Time);
kono
parents:
diff changeset
222 Dated_Rec2 : C340001_0.Dated_Record := (Key => 77,
kono
parents:
diff changeset
223 Data => "aaaaaaaaaa",
kono
parents:
diff changeset
224 Retrieval_Time => Some_Time);
kono
parents:
diff changeset
225 Dated_Rec3 : C340001_0.Dated_Record := (Key => 77,
kono
parents:
diff changeset
226 Data => "aaaaaaaaaa",
kono
parents:
diff changeset
227 Retrieval_Time => Another_Time);
kono
parents:
diff changeset
228 -- Dated_Rec1 = Dated_Rec2 if DB_Record."=" used for parent portion
kono
parents:
diff changeset
229 -- Dated_Rec2 /= Dated_Rec3 if extended component is compared
kono
parents:
diff changeset
230 -- using Ada.Calendar.Time."="
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 List1 : C340001_1.List;
kono
parents:
diff changeset
233 List2 : C340001_1.List;
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 RList1 : C340001_1.Revisable_List;
kono
parents:
diff changeset
236 RList2 : C340001_1.Revisable_List;
kono
parents:
diff changeset
237 RList3 : C340001_1.Revisable_List;
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 Current : C340001_2.Transaction (C340001_2.Paper) :=
kono
parents:
diff changeset
240 (C340001_2.Paper, 2001);
kono
parents:
diff changeset
241 Last : C340001_2.Transaction (C340001_2.Electronic) :=
kono
parents:
diff changeset
242 (C340001_2.Electronic, 2001);
kono
parents:
diff changeset
243 -- Current = Last using user-defined equality
kono
parents:
diff changeset
244 -- Current /= Last using predefined equality
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 Approval1 : C340001_2.Authorization (C340001_2.Paper)
kono
parents:
diff changeset
247 := (Kind => C340001_2.Paper,
kono
parents:
diff changeset
248 ID => 1040,
kono
parents:
diff changeset
249 Signature_On_File => True);
kono
parents:
diff changeset
250 Approval2 : C340001_2.Authorization (C340001_2.Paper)
kono
parents:
diff changeset
251 := (Kind => C340001_2.Paper,
kono
parents:
diff changeset
252 ID => 2167,
kono
parents:
diff changeset
253 Signature_On_File => False);
kono
parents:
diff changeset
254 Approval3 : C340001_2.Authorization (C340001_2.Electronic)
kono
parents:
diff changeset
255 := (Kind => C340001_2.Electronic,
kono
parents:
diff changeset
256 ID => 2167,
kono
parents:
diff changeset
257 Paper_Backup => False);
kono
parents:
diff changeset
258 -- Approval1 /= Approval2 if user-defined equality extended with
kono
parents:
diff changeset
259 -- component equality.
kono
parents:
diff changeset
260 -- Approval2 /= Approval3 if differing variant parts checked
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 -- Direct visibility to operator symbols
kono
parents:
diff changeset
263 use type C340001_0.DB_Record;
kono
parents:
diff changeset
264 use type C340001_0.Dated_Record;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 use type C340001_1.List;
kono
parents:
diff changeset
267 use type C340001_1.Revisable_List;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 use type C340001_2.Transaction;
kono
parents:
diff changeset
270 use type C340001_2.Authorization;
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 begin
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 Report.Test ("C340001", "Inheritance of user-defined ""=""");
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 -- Approval1 /= Approval2 if user-defined equality extended with
kono
parents:
diff changeset
277 -- component equality.
kono
parents:
diff changeset
278 -- Approval2 /= Approval3 if differing variant parts checked
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 ---------------------------------------------------------------------
kono
parents:
diff changeset
281 -- Check that "=" and "/=" for the parent type call the user-defined
kono
parents:
diff changeset
282 -- operation
kono
parents:
diff changeset
283 ---------------------------------------------------------------------
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 if not (DB_Rec1 = DB_Rec2) then
kono
parents:
diff changeset
286 Report.Failed ("Nonlimited tagged record: " &
kono
parents:
diff changeset
287 "User-defined equality did not override predefined " &
kono
parents:
diff changeset
288 "equality");
kono
parents:
diff changeset
289 end if;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 if DB_Rec1 /= DB_Rec2 then
kono
parents:
diff changeset
292 Report.Failed ("Nonlimited tagged record: " &
kono
parents:
diff changeset
293 "User-defined equality did not override predefined " &
kono
parents:
diff changeset
294 "inequality as well");
kono
parents:
diff changeset
295 end if;
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 ---------------------------------------------------------------------
kono
parents:
diff changeset
298 -- Check that "=" and "/=" for the type extension use the user-defined
kono
parents:
diff changeset
299 -- equality operations from the parent to compare the inherited
kono
parents:
diff changeset
300 -- components
kono
parents:
diff changeset
301 ---------------------------------------------------------------------
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 if not (Dated_Rec1 = Dated_Rec2) then
kono
parents:
diff changeset
304 Report.Failed ("Nonlimited tagged record: " &
kono
parents:
diff changeset
305 "User-defined equality was not used to compare " &
kono
parents:
diff changeset
306 "components inherited from parent");
kono
parents:
diff changeset
307 end if;
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 if Dated_Rec1 /= Dated_Rec2 then
kono
parents:
diff changeset
310 Report.Failed ("Nonlimited tagged record: " &
kono
parents:
diff changeset
311 "User-defined inequality was not used to compare " &
kono
parents:
diff changeset
312 "components inherited from parent");
kono
parents:
diff changeset
313 end if;
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 ---------------------------------------------------------------------
kono
parents:
diff changeset
316 -- Check that equality and inequality for the type extension incorporate
kono
parents:
diff changeset
317 -- the predefined equality operators for the extended component type
kono
parents:
diff changeset
318 ---------------------------------------------------------------------
kono
parents:
diff changeset
319 if Dated_Rec2 = Dated_Rec3 then
kono
parents:
diff changeset
320 Report.Failed ("Nonlimited tagged record: " &
kono
parents:
diff changeset
321 "Record equality was not extended with component " &
kono
parents:
diff changeset
322 "equality");
kono
parents:
diff changeset
323 end if;
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 if not (Dated_Rec2 /= Dated_Rec3) then
kono
parents:
diff changeset
326 Report.Failed ("Nonlimited tagged record: " &
kono
parents:
diff changeset
327 "Record inequality was not extended with component " &
kono
parents:
diff changeset
328 "equality");
kono
parents:
diff changeset
329 end if;
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 ---------------------------------------------------------------------
kono
parents:
diff changeset
332 C340001_1.Add_To (List1, 1);
kono
parents:
diff changeset
333 C340001_1.Add_To (List1, 2);
kono
parents:
diff changeset
334 C340001_1.Add_To (List1, 3);
kono
parents:
diff changeset
335 C340001_1.Remove_From (List1);
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 C340001_1.Add_To (List2, 1);
kono
parents:
diff changeset
338 C340001_1.Add_To (List2, 2);
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 -- List1 contents are (2, (1, 2, 3, 0, 0, 0, 0, 0, 0, 0))
kono
parents:
diff changeset
341 -- List2 contents are (2, (1, 2, 0, 0, 0, 0, 0, 0, 0, 0))
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 -- List1 = List2 using user-defined equality
kono
parents:
diff changeset
344 -- List1 /= List2 using predefined equality
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 ---------------------------------------------------------------------
kono
parents:
diff changeset
347 -- Check that "=" and "/=" for the parent type call the user-defined
kono
parents:
diff changeset
348 -- operation
kono
parents:
diff changeset
349 ---------------------------------------------------------------------
kono
parents:
diff changeset
350 if not (List1 = List2) then
kono
parents:
diff changeset
351 Report.Failed ("Limited tagged record : " &
kono
parents:
diff changeset
352 "User-defined equality incorrectly implemented " );
kono
parents:
diff changeset
353 end if;
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 if List1 /= List2 then
kono
parents:
diff changeset
356 Report.Failed ("Limited tagged record : " &
kono
parents:
diff changeset
357 "User-defined equality incorrectly implemented " );
kono
parents:
diff changeset
358 end if;
kono
parents:
diff changeset
359
kono
parents:
diff changeset
360 ---------------------------------------------------------------------
kono
parents:
diff changeset
361 -- RList1 and RList2 are made equal but "different" by adding
kono
parents:
diff changeset
362 -- a nonzero value to RList1 then removing it. Removal updates
kono
parents:
diff changeset
363 -- the list Length only, not its contents. The two lists will be
kono
parents:
diff changeset
364 -- equal according to the defined list abstraction, but the records
kono
parents:
diff changeset
365 -- will contain differing component values.
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 C340001_1.Add_To (RList1, 1);
kono
parents:
diff changeset
368 C340001_1.Add_To (RList1, 2);
kono
parents:
diff changeset
369 C340001_1.Add_To (RList1, 3);
kono
parents:
diff changeset
370 C340001_1.Remove_From (RList1);
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 C340001_1.Add_To (RList2, 1);
kono
parents:
diff changeset
373 C340001_1.Add_To (RList2, 2);
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 C340001_1.Add_To (RList3, 1);
kono
parents:
diff changeset
376 C340001_1.Add_To (RList3, 2);
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 C340001_1.Revise (RList3);
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 -- RList1 contents are (2, (1, 2, 3, 0, 0, 0, 0, 0, 0, 0), 'A')
kono
parents:
diff changeset
381 -- RList2 contents are (2, (1, 2, 0, 0, 0, 0, 0, 0, 0, 0), 'A')
kono
parents:
diff changeset
382 -- RList3 contents are (2, (1, 2, 0, 0, 0, 0, 0, 0, 0, 0), 'B')
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 -- RList1 = RList2 if List."=" inherited
kono
parents:
diff changeset
385 -- RList2 /= RList3 if List."=" inherited and extended with Character "="
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 ---------------------------------------------------------------------
kono
parents:
diff changeset
388 -- Check that "=" and "/=" are the user-defined operations inherited
kono
parents:
diff changeset
389 -- from the parent type.
kono
parents:
diff changeset
390 ---------------------------------------------------------------------
kono
parents:
diff changeset
391 if not (RList1 = RList2) then
kono
parents:
diff changeset
392 Report.Failed ("Limited tagged record : " &
kono
parents:
diff changeset
393 "User-defined equality was not inherited");
kono
parents:
diff changeset
394 end if;
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 if RList1 /= RList2 then
kono
parents:
diff changeset
397 Report.Failed ("Limited tagged record : " &
kono
parents:
diff changeset
398 "User-defined inequality was not inherited");
kono
parents:
diff changeset
399 end if;
kono
parents:
diff changeset
400 ---------------------------------------------------------------------
kono
parents:
diff changeset
401 -- Check that "=" and "/=" for the type extension are NOT extended
kono
parents:
diff changeset
402 -- with the predefined equality operators for the extended component.
kono
parents:
diff changeset
403 -- A limited type extension should inherit the parent equality operation
kono
parents:
diff changeset
404 -- as is.
kono
parents:
diff changeset
405 ---------------------------------------------------------------------
kono
parents:
diff changeset
406 if not (RList2 = RList3) then
kono
parents:
diff changeset
407 Report.Failed ("Limited tagged record : " &
kono
parents:
diff changeset
408 "Inherited equality operation was extended with " &
kono
parents:
diff changeset
409 "component equality");
kono
parents:
diff changeset
410 end if;
kono
parents:
diff changeset
411
kono
parents:
diff changeset
412 if RList2 /= RList3 then
kono
parents:
diff changeset
413 Report.Failed ("Limited tagged record : " &
kono
parents:
diff changeset
414 "Inherited inequality operation was extended with " &
kono
parents:
diff changeset
415 "component equality");
kono
parents:
diff changeset
416 end if;
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 ---------------------------------------------------------------------
kono
parents:
diff changeset
419 -- Check that "=" and "/=" for the parent type call the user-defined
kono
parents:
diff changeset
420 -- operation
kono
parents:
diff changeset
421 ---------------------------------------------------------------------
kono
parents:
diff changeset
422 if not (Current = Last) then
kono
parents:
diff changeset
423 Report.Failed ("Variant record : " &
kono
parents:
diff changeset
424 "User-defined equality did not override predefined " &
kono
parents:
diff changeset
425 "equality");
kono
parents:
diff changeset
426 end if;
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 if Current /= Last then
kono
parents:
diff changeset
429 Report.Failed ("Variant record : " &
kono
parents:
diff changeset
430 "User-defined inequality did not override predefined " &
kono
parents:
diff changeset
431 "inequality");
kono
parents:
diff changeset
432 end if;
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 ---------------------------------------------------------------------
kono
parents:
diff changeset
435 -- Check that user-defined equality was incorporated and extended
kono
parents:
diff changeset
436 -- with equality of extended components.
kono
parents:
diff changeset
437 ---------------------------------------------------------------------
kono
parents:
diff changeset
438 if not (Approval1 /= Approval2) then
kono
parents:
diff changeset
439 Report.Failed ("Variant record : " &
kono
parents:
diff changeset
440 "Inequality was not extended with component " &
kono
parents:
diff changeset
441 "inequality");
kono
parents:
diff changeset
442 end if;
kono
parents:
diff changeset
443
kono
parents:
diff changeset
444 if Approval1 = Approval2 then
kono
parents:
diff changeset
445 Report.Failed ("Variant record : " &
kono
parents:
diff changeset
446 "Equality was not extended with component " &
kono
parents:
diff changeset
447 "equality");
kono
parents:
diff changeset
448 end if;
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 ---------------------------------------------------------------------
kono
parents:
diff changeset
451 -- Check that equality and inequality for the type extension
kono
parents:
diff changeset
452 -- succeed despite the presence of differing variant parts.
kono
parents:
diff changeset
453 ---------------------------------------------------------------------
kono
parents:
diff changeset
454 if Approval2 = Approval3 then
kono
parents:
diff changeset
455 Report.Failed ("Variant record : " &
kono
parents:
diff changeset
456 "Equality succeeded even though variant parts " &
kono
parents:
diff changeset
457 "in type extension differ");
kono
parents:
diff changeset
458 end if;
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 if not (Approval2 /= Approval3) then
kono
parents:
diff changeset
461 Report.Failed ("Variant record : " &
kono
parents:
diff changeset
462 "Inequality failed even though variant parts " &
kono
parents:
diff changeset
463 "in type extension differ");
kono
parents:
diff changeset
464 end if;
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 ---------------------------------------------------------------------
kono
parents:
diff changeset
467 Report.Result;
kono
parents:
diff changeset
468 ---------------------------------------------------------------------
kono
parents:
diff changeset
469
kono
parents:
diff changeset
470 end C340001;