annotate gcc/testsuite/ada/acats/tests/cc/cc70c01.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 -- CC70C01.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 generic formal package is an instance. Specifically,
kono
parents:
diff changeset
28 -- check that a generic formal package may be passed as an actual
kono
parents:
diff changeset
29 -- parameter in an instantiation of a generic package. Check that the
kono
parents:
diff changeset
30 -- visible part of the generic formal package includes the first list of
kono
parents:
diff changeset
31 -- basic declarative items of the package specification.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION:
kono
parents:
diff changeset
34 -- A generic formal package is a package, and is an instance.
kono
parents:
diff changeset
35 --
kono
parents:
diff changeset
36 -- Declare a list type in a generic package for lists of elements of any
kono
parents:
diff changeset
37 -- nonlimited type (foundation code). Declare a second generic package
kono
parents:
diff changeset
38 -- which declares operations for the list type, and parameterize it with
kono
parents:
diff changeset
39 -- a generic formal package with the list-type package as template
kono
parents:
diff changeset
40 -- (foundation code). Declare a third generic package which declares
kono
parents:
diff changeset
41 -- additional operations for the list type, and parameterize it just like
kono
parents:
diff changeset
42 -- the second generic package. Declare an instance of the second generic
kono
parents:
diff changeset
43 -- in the spec of the third generic, passing the formal package as the
kono
parents:
diff changeset
44 -- actual.
kono
parents:
diff changeset
45 --
kono
parents:
diff changeset
46 -- TEST FILES:
kono
parents:
diff changeset
47 -- The following files comprise this test:
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- FC70C00.A
kono
parents:
diff changeset
50 -- CC70C01.A
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- CHANGE HISTORY:
kono
parents:
diff changeset
54 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 --!
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 with FC70C00_0; -- List abstraction.
kono
parents:
diff changeset
59 with FC70C00_1; -- Basic list operations.
kono
parents:
diff changeset
60 generic
kono
parents:
diff changeset
61 with package Lists is new FC70C00_0 (<>);
kono
parents:
diff changeset
62 package CC70C01_0 is -- Additional list operations.
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- Instantiate a generic package (FC70C00_1) with a generic formal package
kono
parents:
diff changeset
65 -- (Lists). This ensures that the package passed as an actual corresponding
kono
parents:
diff changeset
66 -- to Lists is the same one passed as an actual to FC70C00_1. Thus, all list
kono
parents:
diff changeset
67 -- operations from both FC70C00_1 and this package operate on lists of the
kono
parents:
diff changeset
68 -- same element type.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 package Basic_List_Ops is new FC70C00_1 (Lists);
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 End_of_List_Reached : exception;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 -- Read from current element and advance "current" pointer.
kono
parents:
diff changeset
77 procedure Read_Element (L : in out Lists.List_Type;
kono
parents:
diff changeset
78 E : out Lists.Element_Type);
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 -- Add element to end of list.
kono
parents:
diff changeset
81 procedure Add_Element (L : in out Lists.List_Type;
kono
parents:
diff changeset
82 E : in Lists.Element_Type);
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 end CC70C01_0;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 --==================================================================--
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 package body CC70C01_0 is
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 procedure Read_Element (L : in out Lists.List_Type;
kono
parents:
diff changeset
93 E : out Lists.Element_Type) is
kono
parents:
diff changeset
94 begin
kono
parents:
diff changeset
95 if Basic_List_Ops.End_Of_List (L) then -- Use of op from the previous
kono
parents:
diff changeset
96 raise End_Of_List_Reached; -- generic package.
kono
parents:
diff changeset
97 else
kono
parents:
diff changeset
98 E := L.Current.Item; -- Retrieve current element.
kono
parents:
diff changeset
99 L.Current := L.Current.Next; -- Advance "current" pointer.
kono
parents:
diff changeset
100 end if;
kono
parents:
diff changeset
101 end Read_Element;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Add_Element (L : in out Lists.List_Type;
kono
parents:
diff changeset
105 E : in Lists.Element_Type) is
kono
parents:
diff changeset
106 New_Node : Lists.Node_Pointer := new Lists.Node_Type'(E, null);
kono
parents:
diff changeset
107 use type Lists.Node_Pointer;
kono
parents:
diff changeset
108 begin
kono
parents:
diff changeset
109 if L.First = null then -- No elements in list, so add new
kono
parents:
diff changeset
110 L.First := New_Node; -- element at beginning of list.
kono
parents:
diff changeset
111 else
kono
parents:
diff changeset
112 L.Last.Next := New_Node; -- Add new element at end of list.
kono
parents:
diff changeset
113 end if;
kono
parents:
diff changeset
114 L.Last := New_Node; -- Set last-in-list pointer.
kono
parents:
diff changeset
115 end Add_Element;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 end CC70C01_0;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 --==================================================================--
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 with FC70C00_0; -- Generic list abstraction.
kono
parents:
diff changeset
125 with CC70C01_0; -- Additional generic list operations.
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 with Report;
kono
parents:
diff changeset
128 procedure CC70C01 is
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 type Points is range 0 .. 100; -- Discrete type.
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 package Lists_of_Points is new FC70C00_0 (Points); -- Points lists.
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 package Points_List_Ops is new -- Points-list ops.
kono
parents:
diff changeset
135 CC70C01_0 (Lists_Of_Points);
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 Scores : Lists_of_Points.List_Type; -- List of points.
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 -- Begin test code declarations: -----------------------
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 type TC_Score_Array is array (1 .. 3) of Points;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 TC_List_Values : constant TC_Score_Array := (23, 15, 0);
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 TC_Correct_List_Values : Boolean := False;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 procedure TC_Initialize_List (L : in out Lists_Of_Points.List_Type) is
kono
parents:
diff changeset
150 begin -- Initial list contains 3 scores
kono
parents:
diff changeset
151 for I in TC_Score_Array'Range loop -- with the values 23, 15, and 0.
kono
parents:
diff changeset
152 Points_List_Ops.Add_Element (L, TC_List_Values(I));
kono
parents:
diff changeset
153 end loop;
kono
parents:
diff changeset
154 end TC_Initialize_List;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 procedure TC_Verify_List (L : in out Lists_Of_Points.List_Type;
kono
parents:
diff changeset
158 Expected : in TC_Score_Array;
kono
parents:
diff changeset
159 OK : out Boolean) is
kono
parents:
diff changeset
160 Actual : TC_Score_Array;
kono
parents:
diff changeset
161 begin
kono
parents:
diff changeset
162 Points_List_Ops.Basic_List_Ops.Reset (L);
kono
parents:
diff changeset
163 for I in TC_Score_Array'Range loop
kono
parents:
diff changeset
164 Points_List_Ops.Read_Element (L, Actual(I));
kono
parents:
diff changeset
165 end loop;
kono
parents:
diff changeset
166 OK := (Actual = Expected);
kono
parents:
diff changeset
167 end TC_Verify_List;
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 -- End test code declarations. -------------------------
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 begin
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 Report.Test ("CC70C01", "Check that a generic formal package may be " &
kono
parents:
diff changeset
175 "passed as an actual in an instantiation of a generic " &
kono
parents:
diff changeset
176 "package");
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 TC_Initialize_List (Scores);
kono
parents:
diff changeset
179 TC_Verify_List (Scores, TC_List_Values, TC_Correct_List_Values);
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 if not TC_Correct_List_Values then
kono
parents:
diff changeset
182 Report.Failed ("List contains incorrect values");
kono
parents:
diff changeset
183 end if;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 Report.Result;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 end CC70C01;