OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cc/] [cc70c01.a] - Blame information for rev 720

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.