-- CA11014.A
|
-- CA11014.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 an instantiation of a child package of a generic package
|
-- Check that an instantiation of a child package of a generic package
|
-- can use its parent's declarations and operations, including a formal
|
-- can use its parent's declarations and operations, including a formal
|
-- package of the parent.
|
-- package of the parent.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- Declare a list abstraction in a generic package which manages lists of
|
-- Declare a list abstraction in a generic package which manages lists of
|
-- elements of any discrete type. Declare a generic package which
|
-- elements of any discrete type. Declare a generic package which
|
-- operates on lists of elements of integer types. Declare a generic
|
-- operates on lists of elements of integer types. Declare a generic
|
-- child of this package which defines additional list operations.
|
-- child of this package which defines additional list operations.
|
-- Use the formal discrete type as the generic formal actual part for the
|
-- Use the formal discrete type as the generic formal actual part for the
|
-- parent formal package.
|
-- parent formal package.
|
--
|
--
|
-- Declare an instance of parent, then declare an instance of the child
|
-- Declare an instance of parent, then declare an instance of the child
|
-- which is itself a child the parent's instance. In the main program,
|
-- which is itself a child the parent's instance. In the main program,
|
-- check that the operations in both instances perform as expected.
|
-- check that the operations in both instances perform as expected.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 15 Nov 95 SAIC Update and repair for ACVC 2.0.1
|
-- 15 Nov 95 SAIC Update and repair for ACVC 2.0.1
|
-- 07 Sep 96 SAIC Change formal param E to be out only.
|
-- 07 Sep 96 SAIC Change formal param E to be out only.
|
-- 19 Oct 96 SAIC ACVC 2.1: Added pragma Elaborate to context
|
-- 19 Oct 96 SAIC ACVC 2.1: Added pragma Elaborate to context
|
-- clauses of CA11014_0, CA11014_1, and CA11014_5.
|
-- clauses of CA11014_0, CA11014_1, and CA11014_5.
|
-- 27 Feb 97 PWB.CTA Added elaboration pragma at package CA11014_4
|
-- 27 Feb 97 PWB.CTA Added elaboration pragma at package CA11014_4
|
--!
|
--!
|
|
|
-- Actual package for the parent's formal.
|
-- Actual package for the parent's formal.
|
generic
|
generic
|
|
|
type Element_Type is (<>); -- List elems may be of any discrete types.
|
type Element_Type is (<>); -- List elems may be of any discrete types.
|
|
|
package CA11014_0 is
|
package CA11014_0 is
|
|
|
type Node_Type;
|
type Node_Type;
|
type Node_Pointer is access Node_Type;
|
type Node_Pointer is access Node_Type;
|
|
|
type Node_Type is record
|
type Node_Type is record
|
Item : Element_Type;
|
Item : Element_Type;
|
Next : Node_Pointer := null;
|
Next : Node_Pointer := null;
|
end record;
|
end record;
|
|
|
type List_Type is record
|
type List_Type is record
|
First : Node_Pointer := null;
|
First : Node_Pointer := null;
|
Current : Node_Pointer := null;
|
Current : Node_Pointer := null;
|
Last : Node_Pointer := null;
|
Last : Node_Pointer := null;
|
end record;
|
end record;
|
|
|
-- Return true if current element is last in the list.
|
-- Return true if current element is last in the list.
|
function End_Of_List (L : List_Type) return boolean;
|
function End_Of_List (L : List_Type) return boolean;
|
|
|
-- Set "current" pointer to first list element.
|
-- Set "current" pointer to first list element.
|
procedure Reset (L : in out List_Type);
|
procedure Reset (L : in out List_Type);
|
|
|
end CA11014_0;
|
end CA11014_0;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
package body CA11014_0 is
|
package body CA11014_0 is
|
|
|
function End_Of_List (L : List_Type) return boolean is
|
function End_Of_List (L : List_Type) return boolean is
|
begin
|
begin
|
return (L.Current = null);
|
return (L.Current = null);
|
end End_Of_List;
|
end End_Of_List;
|
-------------------------------------------------------
|
-------------------------------------------------------
|
procedure Reset (L : in out List_Type) is
|
procedure Reset (L : in out List_Type) is
|
begin
|
begin
|
L.Current := L.First; -- Set "current" pointer to first
|
L.Current := L.First; -- Set "current" pointer to first
|
end Reset; -- list element.
|
end Reset; -- list element.
|
|
|
end CA11014_0;
|
end CA11014_0;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
with CA11014_0; -- Generic list abstraction.
|
with CA11014_0; -- Generic list abstraction.
|
pragma Elaborate (CA11014_0);
|
pragma Elaborate (CA11014_0);
|
generic
|
generic
|
|
|
-- Import the list abstraction defined in CA11014_0.
|
-- Import the list abstraction defined in CA11014_0.
|
with package List_Mgr is new CA11014_0 (<>);
|
with package List_Mgr is new CA11014_0 (<>);
|
|
|
package CA11014_1 is
|
package CA11014_1 is
|
|
|
-- Write to current element and advance "current" pointer.
|
-- Write to current element and advance "current" pointer.
|
procedure Write_Element (L : in out List_Mgr.List_Type;
|
procedure Write_Element (L : in out List_Mgr.List_Type;
|
E : in List_Mgr.Element_Type);
|
E : in List_Mgr.Element_Type);
|
|
|
-- Read from current element and advance "current" pointer.
|
-- Read from current element and advance "current" pointer.
|
procedure Read_Element (L : in out List_Mgr.List_Type;
|
procedure Read_Element (L : in out List_Mgr.List_Type;
|
E : out List_Mgr.Element_Type);
|
E : out List_Mgr.Element_Type);
|
|
|
-- Add element to end of list.
|
-- Add element to end of list.
|
procedure Add_Element (L : in out List_Mgr.List_Type;
|
procedure Add_Element (L : in out List_Mgr.List_Type;
|
E : in List_Mgr.Element_Type);
|
E : in List_Mgr.Element_Type);
|
|
|
end CA11014_1;
|
end CA11014_1;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
package body CA11014_1 is
|
package body CA11014_1 is
|
|
|
procedure Write_Element (L : in out List_Mgr.List_Type;
|
procedure Write_Element (L : in out List_Mgr.List_Type;
|
E : in List_Mgr.Element_Type) is
|
E : in List_Mgr.Element_Type) is
|
begin
|
begin
|
L.Current.Item := E; -- Write to current element.
|
L.Current.Item := E; -- Write to current element.
|
L.Current := L.Current.Next; -- Advance "current" pointer.
|
L.Current := L.Current.Next; -- Advance "current" pointer.
|
end Write_Element;
|
end Write_Element;
|
-------------------------------------------------------
|
-------------------------------------------------------
|
procedure Read_Element (L : in out List_Mgr.List_Type;
|
procedure Read_Element (L : in out List_Mgr.List_Type;
|
E : out List_Mgr.Element_Type) is
|
E : out List_Mgr.Element_Type) is
|
begin
|
begin
|
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 Read_Element;
|
end Read_Element;
|
-------------------------------------------------------
|
-------------------------------------------------------
|
procedure Add_Element (L : in out List_Mgr.List_Type;
|
procedure Add_Element (L : in out List_Mgr.List_Type;
|
E : in List_Mgr.Element_Type) is
|
E : in List_Mgr.Element_Type) is
|
New_Node : List_Mgr.Node_Pointer := new List_Mgr.Node_Type'(E, null);
|
New_Node : List_Mgr.Node_Pointer := new List_Mgr.Node_Type'(E, null);
|
use type List_Mgr.Node_Pointer;
|
use type List_Mgr.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 CA11014_1;
|
end CA11014_1;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
-- Generic child of list operation. This child adds a layer of
|
-- Generic child of list operation. This child adds a layer of
|
-- functionality to the parent generic.
|
-- functionality to the parent generic.
|
|
|
generic
|
generic
|
|
|
package CA11014_1.CA11014_2 is
|
package CA11014_1.CA11014_2 is
|
|
|
procedure Write_First_To_List (L : in out List_Mgr.List_Type);
|
procedure Write_First_To_List (L : in out List_Mgr.List_Type);
|
|
|
-- ... Various other operations used by the application.
|
-- ... Various other operations used by the application.
|
|
|
end CA11014_1.CA11014_2;
|
end CA11014_1.CA11014_2;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
package body CA11014_1.CA11014_2 is
|
package body CA11014_1.CA11014_2 is
|
|
|
procedure Write_First_To_List (L : in out List_Mgr.List_Type) is
|
procedure Write_First_To_List (L : in out List_Mgr.List_Type) is
|
begin
|
begin
|
List_Mgr.Reset (L); -- Parent's formal package.
|
List_Mgr.Reset (L); -- Parent's formal package.
|
|
|
while not List_Mgr.End_Of_List (L) loop -- Parent's formal package.
|
while not List_Mgr.End_Of_List (L) loop -- Parent's formal package.
|
Write_Element (L, List_Mgr.Element_Type'First);
|
Write_Element (L, List_Mgr.Element_Type'First);
|
-- Parent's operation,
|
-- Parent's operation,
|
end loop; -- parent's formal.
|
end loop; -- parent's formal.
|
|
|
end Write_First_To_List;
|
end Write_First_To_List;
|
|
|
end CA11014_1.CA11014_2;
|
end CA11014_1.CA11014_2;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
package CA11014_3 is
|
package CA11014_3 is
|
|
|
type Points is range 0 .. 100;
|
type Points is range 0 .. 100;
|
|
|
-- ... Various other types used by the application.
|
-- ... Various other types used by the application.
|
|
|
end CA11014_3;
|
end CA11014_3;
|
|
|
|
|
-- No body for CA11014_3;
|
-- No body for CA11014_3;
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
-- Declare instances of the generic list packages for the discrete type.
|
-- Declare instances of the generic list packages for the discrete type.
|
-- The instance of the child must itself be declared as a child of the
|
-- The instance of the child must itself be declared as a child of the
|
-- instance of the parent.
|
-- instance of the parent.
|
|
|
with CA11014_0; -- Generic list abstraction.
|
with CA11014_0; -- Generic list abstraction.
|
with CA11014_3; -- Package containing discrete type declaration.
|
with CA11014_3; -- Package containing discrete type declaration.
|
pragma Elaborate (CA11014_0);
|
pragma Elaborate (CA11014_0);
|
package CA11014_4 is new CA11014_0 (CA11014_3.Points); -- Points list.
|
package CA11014_4 is new CA11014_0 (CA11014_3.Points); -- Points list.
|
|
|
with CA11014_4; -- Points list.
|
with CA11014_4; -- Points list.
|
with CA11014_1; -- Generic list operation.
|
with CA11014_1; -- Generic list operation.
|
pragma Elaborate (CA11014_1);
|
pragma Elaborate (CA11014_1);
|
package CA11014_5 is new CA11014_1 (CA11014_4); -- Scores list.
|
package CA11014_5 is new CA11014_1 (CA11014_4); -- Scores list.
|
|
|
with CA11014_1.CA11014_2; -- Additional generic list operation,
|
with CA11014_1.CA11014_2; -- Additional generic list operation,
|
with CA11014_5;
|
with CA11014_5;
|
pragma Elaborate (CA11014_5);
|
pragma Elaborate (CA11014_5);
|
package CA11014_5.CA11014_6 is new CA11014_5.CA11014_2;
|
package CA11014_5.CA11014_6 is new CA11014_5.CA11014_2;
|
-- Points list operation.
|
-- Points list operation.
|
|
|
--==================================================================--
|
--==================================================================--
|
|
|
with CA11014_1.CA11014_2; -- Additional generic list operation,
|
with CA11014_1.CA11014_2; -- Additional generic list operation,
|
-- implicitly with list operation.
|
-- implicitly with list operation.
|
with CA11014_3; -- Package containing discrete type declaration.
|
with CA11014_3; -- Package containing discrete type declaration.
|
with CA11014_4; -- Points list.
|
with CA11014_4; -- Points list.
|
with CA11014_5.CA11014_6; -- Points list operation.
|
with CA11014_5.CA11014_6; -- Points list operation.
|
with Report;
|
with Report;
|
|
|
procedure CA11014 is
|
procedure CA11014 is
|
|
|
package Lists_Of_Scores renames CA11014_4;
|
package Lists_Of_Scores renames CA11014_4;
|
package Score_Ops renames CA11014_5;
|
package Score_Ops renames CA11014_5;
|
package Point_Ops renames CA11014_5.CA11014_6;
|
package Point_Ops renames CA11014_5.CA11014_6;
|
|
|
Scores : Lists_Of_Scores.List_Type; -- List of points.
|
Scores : Lists_Of_Scores.List_Type; -- List of points.
|
|
|
type TC_Score_Array is array (1 .. 3) of CA11014_3.Points;
|
type TC_Score_Array is array (1 .. 3) of CA11014_3.Points;
|
|
|
TC_Initial_Values : constant TC_Score_Array := (10, 21, 49);
|
TC_Initial_Values : constant TC_Score_Array := (10, 21, 49);
|
TC_Final_Values : constant TC_Score_Array := (0, 0, 0);
|
TC_Final_Values : constant TC_Score_Array := (0, 0, 0);
|
|
|
TC_Initial_Values_Are_Correct : boolean := false;
|
TC_Initial_Values_Are_Correct : boolean := false;
|
TC_Final_Values_Are_Correct : boolean := false;
|
TC_Final_Values_Are_Correct : boolean := false;
|
|
|
--------------------------------------------------
|
--------------------------------------------------
|
|
|
-- Initial list contains 3 scores with the values 10, 21, and 49.
|
-- Initial list contains 3 scores with the values 10, 21, and 49.
|
procedure TC_Initialize_List (L : in out Lists_of_Scores.List_Type) is
|
procedure TC_Initialize_List (L : in out Lists_of_Scores.List_Type) is
|
begin
|
begin
|
for I in TC_Score_Array'range loop
|
for I in TC_Score_Array'range loop
|
Score_Ops.Add_Element (L, TC_Initial_Values(I));
|
Score_Ops.Add_Element (L, TC_Initial_Values(I));
|
-- Operation from generic parent.
|
-- Operation from generic parent.
|
end loop;
|
end loop;
|
end TC_Initialize_List;
|
end TC_Initialize_List;
|
|
|
--------------------------------------------------
|
--------------------------------------------------
|
|
|
-- Verify that all scores have been set to zero.
|
-- Verify that all scores have been set to zero.
|
procedure TC_Verify_List (L : in out Lists_of_Scores.List_Type;
|
procedure TC_Verify_List (L : in out Lists_of_Scores.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
|
Lists_of_Scores.Reset (L); -- Operation from parent's formal.
|
Lists_of_Scores.Reset (L); -- Operation from parent's formal.
|
for I in TC_Score_Array'range loop
|
for I in TC_Score_Array'range loop
|
Score_Ops.Read_Element (L, Actual(I));
|
Score_Ops.Read_Element (L, Actual(I));
|
-- Operation from generic parent.
|
-- Operation from generic parent.
|
end loop;
|
end loop;
|
OK := (Actual = Expected);
|
OK := (Actual = Expected);
|
end TC_Verify_List;
|
end TC_Verify_List;
|
|
|
--------------------------------------------------
|
--------------------------------------------------
|
|
|
begin -- CA11014
|
begin -- CA11014
|
|
|
Report.Test ("CA11014", "Check that an instantiation of a child package " &
|
Report.Test ("CA11014", "Check that an instantiation of a child package " &
|
"of a generic package can use its parent's " &
|
"of a generic package can use its parent's " &
|
"declarations and operations, including a " &
|
"declarations and operations, including a " &
|
"formal package of the parent");
|
"formal package of the parent");
|
|
|
TC_Initialize_List (Scores);
|
TC_Initialize_List (Scores);
|
TC_Verify_List (Scores, TC_Initial_Values, TC_Initial_Values_Are_Correct);
|
TC_Verify_List (Scores, TC_Initial_Values, TC_Initial_Values_Are_Correct);
|
|
|
if not TC_Initial_Values_Are_Correct then
|
if not TC_Initial_Values_Are_Correct then
|
Report.Failed ("List contains incorrect initial values");
|
Report.Failed ("List contains incorrect initial values");
|
end if;
|
end if;
|
|
|
Point_Ops.Write_First_To_List (Scores);
|
Point_Ops.Write_First_To_List (Scores);
|
-- Operation from generic child package.
|
-- Operation from generic child package.
|
|
|
TC_Verify_List (Scores, TC_Final_Values, TC_Final_Values_Are_Correct);
|
TC_Verify_List (Scores, TC_Final_Values, TC_Final_Values_Are_Correct);
|
|
|
if not TC_Final_Values_Are_Correct then
|
if not TC_Final_Values_Are_Correct then
|
Report.Failed ("List contains incorrect final values");
|
Report.Failed ("List contains incorrect final values");
|
end if;
|
end if;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end CA11014;
|
end CA11014;
|
|
|