-- CC70C01.A
|
-- CC70C01.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that a generic formal package is an instance. Specifically,
|
-- Check that a generic formal package is an instance. Specifically,
|
-- check that a generic formal package may be passed as an actual
|
-- check that a generic formal package may be passed as an actual
|
-- parameter in an instantiation of a generic package. Check that the
|
-- parameter in an instantiation of a generic package. Check that the
|
-- visible part of the generic formal package includes the first list of
|
-- visible part of the generic formal package includes the first list of
|
-- basic declarative items of the package specification.
|
-- basic declarative items of the package specification.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- A generic formal package is a package, and is an instance.
|
-- A generic formal package is a package, and is an instance.
|
--
|
--
|
-- Declare a list type in a generic package for lists of elements of any
|
-- Declare a list type in a generic package for lists of elements of any
|
-- nonlimited type (foundation code). Declare a second generic package
|
-- nonlimited type (foundation code). Declare a second generic package
|
-- which declares operations for the list type, and parameterize it with
|
-- which declares operations for the list type, and parameterize it with
|
-- a generic formal package with the list-type package as template
|
-- a generic formal package with the list-type package as template
|
-- (foundation code). Declare a third generic package which declares
|
-- (foundation code). Declare a third generic package which declares
|
-- additional operations for the list type, and parameterize it just like
|
-- additional operations for the list type, and parameterize it just like
|
-- the second generic package. Declare an instance of the second generic
|
-- the second generic package. Declare an instance of the second generic
|
-- in the spec of the third generic, passing the formal package as the
|
-- in the spec of the third generic, passing the formal package as the
|
-- actual.
|
-- actual.
|
--
|
--
|
-- TEST FILES:
|
-- TEST FILES:
|
-- The following files comprise this test:
|
-- The following files comprise this test:
|
--
|
--
|
-- FC70C00.A
|
-- FC70C00.A
|
-- CC70C01.A
|
-- CC70C01.A
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
--
|
--
|
--!
|
--!
|
|
|
with FC70C00_0; -- List abstraction.
|
with FC70C00_0; -- List abstraction.
|
with FC70C00_1; -- Basic list operations.
|
with FC70C00_1; -- Basic list operations.
|
generic
|
generic
|
with package Lists is new FC70C00_0 (<>);
|
with package Lists is new FC70C00_0 (<>);
|
package CC70C01_0 is -- Additional list operations.
|
package CC70C01_0 is -- Additional list operations.
|
|
|
-- Instantiate a generic package (FC70C00_1) with a generic formal package
|
-- Instantiate a generic package (FC70C00_1) with a generic formal package
|
-- (Lists). This ensures that the package passed as an actual corresponding
|
-- (Lists). This ensures that the package passed as an actual corresponding
|
-- to Lists is the same one passed as an actual to FC70C00_1. Thus, all list
|
-- to Lists is the same one passed as an actual to FC70C00_1. Thus, all list
|
-- operations from both FC70C00_1 and this package operate on lists of the
|
-- operations from both FC70C00_1 and this package operate on lists of the
|
-- same element type.
|
-- same element type.
|
|
|
package Basic_List_Ops is new FC70C00_1 (Lists);
|
package Basic_List_Ops is new FC70C00_1 (Lists);
|
|
|
|
|
End_of_List_Reached : exception;
|
End_of_List_Reached : exception;
|
|
|
|
|
-- Read from current element and advance "current" pointer.
|
-- Read from current element and advance "current" pointer.
|
procedure Read_Element (L : in out Lists.List_Type;
|
procedure Read_Element (L : in out Lists.List_Type;
|
E : out Lists.Element_Type);
|
E : out Lists.Element_Type);
|
|
|
-- Add element to end of list.
|
-- Add element to end of list.
|
procedure Add_Element (L : in out Lists.List_Type;
|
procedure Add_Element (L : in out Lists.List_Type;
|
E : in Lists.Element_Type);
|
E : in Lists.Element_Type);
|
|
|
end CC70C01_0;
|
end CC70C01_0;
|
|
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
|
|
package body CC70C01_0 is
|
package body CC70C01_0 is
|
|
|
procedure Read_Element (L : in out Lists.List_Type;
|
procedure Read_Element (L : in out Lists.List_Type;
|
E : out Lists.Element_Type) is
|
E : out Lists.Element_Type) is
|
begin
|
begin
|
if Basic_List_Ops.End_Of_List (L) then -- Use of op from the previous
|
if Basic_List_Ops.End_Of_List (L) then -- Use of op from the previous
|
raise End_Of_List_Reached; -- generic package.
|
raise End_Of_List_Reached; -- generic package.
|
else
|
else
|
E := L.Current.Item; -- Retrieve current element.
|
E := L.Current.Item; -- Retrieve current element.
|
L.Current := L.Current.Next; -- Advance "current" pointer.
|
L.Current := L.Current.Next; -- Advance "current" pointer.
|
end if;
|
end if;
|
end Read_Element;
|
end Read_Element;
|
|
|
|
|
procedure Add_Element (L : in out Lists.List_Type;
|
procedure Add_Element (L : in out Lists.List_Type;
|
E : in Lists.Element_Type) is
|
E : in Lists.Element_Type) is
|
New_Node : Lists.Node_Pointer := new Lists.Node_Type'(E, null);
|
New_Node : Lists.Node_Pointer := new Lists.Node_Type'(E, null);
|
use type Lists.Node_Pointer;
|
use type Lists.Node_Pointer;
|
begin
|
begin
|
if L.First = null then -- No elements in list, so add new
|
if L.First = null then -- No elements in list, so add new
|
L.First := New_Node; -- element at beginning of list.
|
L.First := New_Node; -- element at beginning of list.
|
else
|
else
|
L.Last.Next := New_Node; -- Add new element at end of list.
|
L.Last.Next := New_Node; -- Add new element at end of list.
|
end if;
|
end if;
|
L.Last := New_Node; -- Set last-in-list pointer.
|
L.Last := New_Node; -- Set last-in-list pointer.
|
end Add_Element;
|
end Add_Element;
|
|
|
|
|
end CC70C01_0;
|
end CC70C01_0;
|
|
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
|
|
with FC70C00_0; -- Generic list abstraction.
|
with FC70C00_0; -- Generic list abstraction.
|
with CC70C01_0; -- Additional generic list operations.
|
with CC70C01_0; -- Additional generic list operations.
|
|
|
with Report;
|
with Report;
|
procedure CC70C01 is
|
procedure CC70C01 is
|
|
|
type Points is range 0 .. 100; -- Discrete type.
|
type Points is range 0 .. 100; -- Discrete type.
|
|
|
package Lists_of_Points is new FC70C00_0 (Points); -- Points lists.
|
package Lists_of_Points is new FC70C00_0 (Points); -- Points lists.
|
|
|
package Points_List_Ops is new -- Points-list ops.
|
package Points_List_Ops is new -- Points-list ops.
|
CC70C01_0 (Lists_Of_Points);
|
CC70C01_0 (Lists_Of_Points);
|
|
|
Scores : Lists_of_Points.List_Type; -- List of points.
|
Scores : Lists_of_Points.List_Type; -- List of points.
|
|
|
|
|
-- Begin test code declarations: -----------------------
|
-- Begin test code declarations: -----------------------
|
|
|
type TC_Score_Array is array (1 .. 3) of Points;
|
type TC_Score_Array is array (1 .. 3) of Points;
|
|
|
TC_List_Values : constant TC_Score_Array := (23, 15, 0);
|
TC_List_Values : constant TC_Score_Array := (23, 15, 0);
|
|
|
TC_Correct_List_Values : Boolean := False;
|
TC_Correct_List_Values : Boolean := False;
|
|
|
|
|
procedure TC_Initialize_List (L : in out Lists_Of_Points.List_Type) is
|
procedure TC_Initialize_List (L : in out Lists_Of_Points.List_Type) is
|
begin -- Initial list contains 3 scores
|
begin -- Initial list contains 3 scores
|
for I in TC_Score_Array'Range loop -- with the values 23, 15, and 0.
|
for I in TC_Score_Array'Range loop -- with the values 23, 15, and 0.
|
Points_List_Ops.Add_Element (L, TC_List_Values(I));
|
Points_List_Ops.Add_Element (L, TC_List_Values(I));
|
end loop;
|
end loop;
|
end TC_Initialize_List;
|
end TC_Initialize_List;
|
|
|
|
|
procedure TC_Verify_List (L : in out Lists_Of_Points.List_Type;
|
procedure TC_Verify_List (L : in out Lists_Of_Points.List_Type;
|
Expected : in TC_Score_Array;
|
Expected : in TC_Score_Array;
|
OK : out Boolean) is
|
OK : out Boolean) is
|
Actual : TC_Score_Array;
|
Actual : TC_Score_Array;
|
begin
|
begin
|
Points_List_Ops.Basic_List_Ops.Reset (L);
|
Points_List_Ops.Basic_List_Ops.Reset (L);
|
for I in TC_Score_Array'Range loop
|
for I in TC_Score_Array'Range loop
|
Points_List_Ops.Read_Element (L, Actual(I));
|
Points_List_Ops.Read_Element (L, Actual(I));
|
end loop;
|
end loop;
|
OK := (Actual = Expected);
|
OK := (Actual = Expected);
|
end TC_Verify_List;
|
end TC_Verify_List;
|
|
|
-- End test code declarations. -------------------------
|
-- End test code declarations. -------------------------
|
|
|
|
|
begin
|
begin
|
|
|
Report.Test ("CC70C01", "Check that a generic formal package may be " &
|
Report.Test ("CC70C01", "Check that a generic formal package may be " &
|
"passed as an actual in an instantiation of a generic " &
|
"passed as an actual in an instantiation of a generic " &
|
"package");
|
"package");
|
|
|
TC_Initialize_List (Scores);
|
TC_Initialize_List (Scores);
|
TC_Verify_List (Scores, TC_List_Values, TC_Correct_List_Values);
|
TC_Verify_List (Scores, TC_List_Values, TC_Correct_List_Values);
|
|
|
if not TC_Correct_List_Values then
|
if not TC_Correct_List_Values then
|
Report.Failed ("List contains incorrect values");
|
Report.Failed ("List contains incorrect values");
|
end if;
|
end if;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end CC70C01;
|
end CC70C01;
|
|
|