-- CA11003.A
|
-- CA11003.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 public grandchild can utilize its ancestor unit's visible
|
-- Check that a public grandchild can utilize its ancestor unit's visible
|
-- definitions.
|
-- definitions.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- Declare a public package, public child package, and public
|
-- Declare a public package, public child package, and public
|
-- grandchild package and library unit function. Within the
|
-- grandchild package and library unit function. Within the
|
-- grandchild package and function, make use of components that are
|
-- grandchild package and function, make use of components that are
|
-- declared in the ancestor packages, both parent and grandparent.
|
-- declared in the ancestor packages, both parent and grandparent.
|
--
|
--
|
-- Use the following ancestral components in the grandchildren library
|
-- Use the following ancestral components in the grandchildren library
|
-- units:
|
-- units:
|
-- Grandparent Parent
|
-- Grandparent Parent
|
-- Type X X
|
-- Type X X
|
-- Constant X X
|
-- Constant X X
|
-- Object X X
|
-- Object X X
|
-- Subprogram X X
|
-- Subprogram X X
|
-- Exception X X
|
-- Exception X X
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 21 Dec 94 SAIC Modified procedure Create_File
|
-- 21 Dec 94 SAIC Modified procedure Create_File
|
-- 15 Nov 95 SAIC Update and repair for ACVC 2.0.1
|
-- 15 Nov 95 SAIC Update and repair for ACVC 2.0.1
|
--
|
--
|
--!
|
--!
|
|
|
package CA11003_0 is -- Package OS
|
package CA11003_0 is -- Package OS
|
|
|
type File_Descriptor is new Integer;
|
type File_Descriptor is new Integer;
|
type File_Mode is (Read_Only, Write_Only, Read_Write);
|
type File_Mode is (Read_Only, Write_Only, Read_Write);
|
|
|
Null_File : constant File_Descriptor := 0;
|
Null_File : constant File_Descriptor := 0;
|
Default_Mode : constant File_Mode := Read_Only;
|
Default_Mode : constant File_Mode := Read_Only;
|
File_Data_Error : exception;
|
File_Data_Error : exception;
|
|
|
type File_Type is tagged
|
type File_Type is tagged
|
record
|
record
|
Descriptor : File_Descriptor := Null_File;
|
Descriptor : File_Descriptor := Null_File;
|
Mode : File_Mode := Read_Write;
|
Mode : File_Mode := Read_Write;
|
end record;
|
end record;
|
|
|
System_File : File_Type;
|
System_File : File_Type;
|
|
|
function Next_Available_File return File_Descriptor;
|
function Next_Available_File return File_Descriptor;
|
|
|
procedure Reclaim_File_Descriptor;
|
procedure Reclaim_File_Descriptor;
|
|
|
end CA11003_0; -- Package OS
|
end CA11003_0; -- Package OS
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
package body CA11003_0 is -- Package body OS
|
package body CA11003_0 is -- Package body OS
|
|
|
File_Count : Integer := 0;
|
File_Count : Integer := 0;
|
|
|
function Next_Available_File return File_Descriptor is
|
function Next_Available_File return File_Descriptor is
|
begin
|
begin
|
File_Count := File_Count + 1;
|
File_Count := File_Count + 1;
|
return (File_Descriptor(File_Count));
|
return (File_Descriptor(File_Count));
|
end Next_Available_File;
|
end Next_Available_File;
|
--------------------------------------------------
|
--------------------------------------------------
|
procedure Reclaim_File_Descriptor is
|
procedure Reclaim_File_Descriptor is
|
begin
|
begin
|
null; -- Dummy processing unit.
|
null; -- Dummy processing unit.
|
end Reclaim_File_Descriptor;
|
end Reclaim_File_Descriptor;
|
|
|
end CA11003_0; -- Package body OS
|
end CA11003_0; -- Package body OS
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
package CA11003_0.CA11003_1 is -- Child package OS.Operations
|
package CA11003_0.CA11003_1 is -- Child package OS.Operations
|
|
|
subtype File_Length_Type is Integer range 0 .. 1000;
|
subtype File_Length_Type is Integer range 0 .. 1000;
|
Min_File_Size : File_Length_Type := File_Length_Type'First;
|
Min_File_Size : File_Length_Type := File_Length_Type'First;
|
Max_File_Size : File_Length_Type := File_Length_Type'Last;
|
Max_File_Size : File_Length_Type := File_Length_Type'Last;
|
|
|
File_Duplication_Error : exception;
|
File_Duplication_Error : exception;
|
|
|
type Extended_File_Type is new File_Type with private;
|
type Extended_File_Type is new File_Type with private;
|
|
|
procedure Create_File (Mode : in File_Mode;
|
procedure Create_File (Mode : in File_Mode;
|
File : out Extended_File_Type);
|
File : out Extended_File_Type);
|
|
|
procedure Duplicate_File (Original : in Extended_File_Type;
|
procedure Duplicate_File (Original : in Extended_File_Type;
|
Duplicate : out Extended_File_Type);
|
Duplicate : out Extended_File_Type);
|
|
|
private
|
private
|
type Extended_File_Type is new File_Type with
|
type Extended_File_Type is new File_Type with
|
record
|
record
|
Blocks : File_Length_Type := Min_File_Size;
|
Blocks : File_Length_Type := Min_File_Size;
|
end record;
|
end record;
|
|
|
System_Extended_File : Extended_File_Type;
|
System_Extended_File : Extended_File_Type;
|
|
|
end CA11003_0.CA11003_1; -- Child Package OS.Operations
|
end CA11003_0.CA11003_1; -- Child Package OS.Operations
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
package body CA11003_0.CA11003_1 is -- Child package body OS.Operations
|
package body CA11003_0.CA11003_1 is -- Child package body OS.Operations
|
|
|
procedure Create_File
|
procedure Create_File
|
(Mode : in File_Mode;
|
(Mode : in File_Mode;
|
File : out Extended_File_Type) is
|
File : out Extended_File_Type) is
|
begin
|
begin
|
File.Descriptor := Next_Available_File; -- Parent subprogram.
|
File.Descriptor := Next_Available_File; -- Parent subprogram.
|
File.Mode := Default_Mode; -- Parent constant.
|
File.Mode := Default_Mode; -- Parent constant.
|
File.Blocks := Min_File_Size;
|
File.Blocks := Min_File_Size;
|
end Create_File;
|
end Create_File;
|
--------------------------------------------------
|
--------------------------------------------------
|
procedure Duplicate_File (Original : in Extended_File_Type;
|
procedure Duplicate_File (Original : in Extended_File_Type;
|
Duplicate : out Extended_File_Type) is
|
Duplicate : out Extended_File_Type) is
|
begin
|
begin
|
Duplicate.Descriptor := Next_Available_File; -- Parent subprogram.
|
Duplicate.Descriptor := Next_Available_File; -- Parent subprogram.
|
Duplicate.Mode := Original.Mode;
|
Duplicate.Mode := Original.Mode;
|
Duplicate.Blocks := Original.Blocks;
|
Duplicate.Blocks := Original.Blocks;
|
end Duplicate_File;
|
end Duplicate_File;
|
|
|
end CA11003_0.CA11003_1; -- Child package body OS.Operations
|
end CA11003_0.CA11003_1; -- Child package body OS.Operations
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
-- This package contains menu selectable operations for manipulating files.
|
-- This package contains menu selectable operations for manipulating files.
|
-- This abstraction builds on the capabilities available from ancestor
|
-- This abstraction builds on the capabilities available from ancestor
|
-- packages.
|
-- packages.
|
|
|
package CA11003_0.CA11003_1.CA11003_2 is
|
package CA11003_0.CA11003_1.CA11003_2 is
|
|
|
procedure News (Mode : in File_Mode;
|
procedure News (Mode : in File_Mode;
|
File : out Extended_File_Type);
|
File : out Extended_File_Type);
|
|
|
procedure Copy (Original : in Extended_File_Type;
|
procedure Copy (Original : in Extended_File_Type;
|
Duplicate : out Extended_File_Type);
|
Duplicate : out Extended_File_Type);
|
|
|
procedure Delete (File : in Extended_File_Type);
|
procedure Delete (File : in Extended_File_Type);
|
|
|
end CA11003_0.CA11003_1.CA11003_2; -- Grandchild package OS.Operations.Menu
|
end CA11003_0.CA11003_1.CA11003_2; -- Grandchild package OS.Operations.Menu
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
-- Grandchild subprogram Validate
|
-- Grandchild subprogram Validate
|
function CA11003_0.CA11003_1.CA11003_3 (File : in Extended_File_Type)
|
function CA11003_0.CA11003_1.CA11003_3 (File : in Extended_File_Type)
|
return Boolean;
|
return Boolean;
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
-- Grandchild subprogram Validate
|
-- Grandchild subprogram Validate
|
function CA11003_0.CA11003_1.CA11003_3
|
function CA11003_0.CA11003_1.CA11003_3
|
(File : in Extended_File_Type) -- Parent type.
|
(File : in Extended_File_Type) -- Parent type.
|
return Boolean is
|
return Boolean is
|
|
|
function New_File_Validated (File : Extended_File_Type)
|
function New_File_Validated (File : Extended_File_Type)
|
return Boolean is
|
return Boolean is
|
begin
|
begin
|
if (File.Descriptor > System_File.Descriptor) and -- Grandparent
|
if (File.Descriptor > System_File.Descriptor) and -- Grandparent
|
(File.Mode in File_Mode ) and -- object and type
|
(File.Mode in File_Mode ) and -- object and type
|
not ((File.Blocks < System_Extended_File.Blocks) or
|
not ((File.Blocks < System_Extended_File.Blocks) or
|
(File.Blocks > Max_File_Size)) -- Parent object
|
(File.Blocks > Max_File_Size)) -- Parent object
|
then -- and constant.
|
then -- and constant.
|
return True;
|
return True;
|
else
|
else
|
return False;
|
return False;
|
end if;
|
end if;
|
end New_File_Validated;
|
end New_File_Validated;
|
|
|
begin
|
begin
|
return (New_File_Validated (File)) and
|
return (New_File_Validated (File)) and
|
(File.Descriptor /= Null_File); -- Grandparent constant.
|
(File.Descriptor /= Null_File); -- Grandparent constant.
|
|
|
end CA11003_0.CA11003_1.CA11003_3; -- Grandchild subprogram Validate
|
end CA11003_0.CA11003_1.CA11003_3; -- Grandchild subprogram Validate
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
with CA11003_0.CA11003_1.CA11003_3;
|
with CA11003_0.CA11003_1.CA11003_3;
|
-- Grandchild package body OS.Operations.Menu
|
-- Grandchild package body OS.Operations.Menu
|
package body CA11003_0.CA11003_1.CA11003_2 is
|
package body CA11003_0.CA11003_1.CA11003_2 is
|
|
|
procedure News (Mode : in File_Mode;
|
procedure News (Mode : in File_Mode;
|
File : out Extended_File_Type) is -- Parent type.
|
File : out Extended_File_Type) is -- Parent type.
|
begin
|
begin
|
Create_File (Mode, File); -- Parent subprogram.
|
Create_File (Mode, File); -- Parent subprogram.
|
if not CA11003_0.CA11003_1.CA11003_3 (File) then
|
if not CA11003_0.CA11003_1.CA11003_3 (File) then
|
raise File_Data_Error; -- Grandparent exception.
|
raise File_Data_Error; -- Grandparent exception.
|
end if;
|
end if;
|
end News;
|
end News;
|
--------------------------------------------------
|
--------------------------------------------------
|
procedure Copy (Original : in Extended_File_Type;
|
procedure Copy (Original : in Extended_File_Type;
|
Duplicate : out Extended_File_Type) is
|
Duplicate : out Extended_File_Type) is
|
begin
|
begin
|
Duplicate_File (Original, Duplicate); -- Parent subprogram.
|
Duplicate_File (Original, Duplicate); -- Parent subprogram.
|
|
|
if Original.Descriptor = Duplicate.Descriptor then
|
if Original.Descriptor = Duplicate.Descriptor then
|
raise File_Duplication_Error; -- Parent exception.
|
raise File_Duplication_Error; -- Parent exception.
|
end if;
|
end if;
|
|
|
end Copy;
|
end Copy;
|
--------------------------------------------------
|
--------------------------------------------------
|
procedure Delete (File : in Extended_File_Type) is
|
procedure Delete (File : in Extended_File_Type) is
|
begin
|
begin
|
Reclaim_File_Descriptor; -- Grandparent
|
Reclaim_File_Descriptor; -- Grandparent
|
end Delete; -- subprogram.
|
end Delete; -- subprogram.
|
|
|
end CA11003_0.CA11003_1.CA11003_2;
|
end CA11003_0.CA11003_1.CA11003_2;
|
|
|
--=================================================================--
|
--=================================================================--
|
|
|
with CA11003_0.CA11003_1.CA11003_2; -- Grandchild Pkg OS.Operations.Menu
|
with CA11003_0.CA11003_1.CA11003_2; -- Grandchild Pkg OS.Operations.Menu
|
with CA11003_0.CA11003_1.CA11003_3; -- Grandchild Ftn OS.Operations.Validate
|
with CA11003_0.CA11003_1.CA11003_3; -- Grandchild Ftn OS.Operations.Validate
|
with Report;
|
with Report;
|
|
|
procedure CA11003 is
|
procedure CA11003 is
|
|
|
package Menu renames CA11003_0.CA11003_1.CA11003_2;
|
package Menu renames CA11003_0.CA11003_1.CA11003_2;
|
|
|
begin
|
begin
|
|
|
Report.Test ("CA11003", "Check that a public grandchild can utilize " &
|
Report.Test ("CA11003", "Check that a public grandchild can utilize " &
|
"its ancestor unit's visible definitions");
|
"its ancestor unit's visible definitions");
|
|
|
File_Processing: -- Validate all of the capabilities contained in
|
File_Processing: -- Validate all of the capabilities contained in
|
-- the Menu package by exercising them on specific
|
-- the Menu package by exercising them on specific
|
-- files. This will demonstrate the use of child
|
-- files. This will demonstrate the use of child
|
-- and grandchild functionality based on components
|
-- and grandchild functionality based on components
|
-- that have been declared in the
|
-- that have been declared in the
|
-- parent/grandparent package.
|
-- parent/grandparent package.
|
declare
|
declare
|
|
|
function Validate (File : CA11003_0.CA11003_1.Extended_File_Type)
|
function Validate (File : CA11003_0.CA11003_1.Extended_File_Type)
|
return Boolean renames CA11003_0.CA11003_1.CA11003_3;
|
return Boolean renames CA11003_0.CA11003_1.CA11003_3;
|
|
|
MacWrite_File,
|
MacWrite_File,
|
Backup_Copy : CA11003_0.CA11003_1.Extended_File_Type;
|
Backup_Copy : CA11003_0.CA11003_1.Extended_File_Type;
|
MacWrite_File_Mode : CA11003_0.File_Mode := CA11003_0.Read_Write;
|
MacWrite_File_Mode : CA11003_0.File_Mode := CA11003_0.Read_Write;
|
|
|
begin
|
begin
|
|
|
Menu.News (MacWrite_File_Mode, MacWrite_File);
|
Menu.News (MacWrite_File_Mode, MacWrite_File);
|
|
|
if not Validate (MacWrite_File) then
|
if not Validate (MacWrite_File) then
|
Report.Failed ("Incorrect initialization of files");
|
Report.Failed ("Incorrect initialization of files");
|
end if;
|
end if;
|
|
|
Menu.Copy (MacWrite_File, Backup_Copy);
|
Menu.Copy (MacWrite_File, Backup_Copy);
|
|
|
if not (Validate (MacWrite_File) and
|
if not (Validate (MacWrite_File) and
|
Validate (Backup_Copy))
|
Validate (Backup_Copy))
|
then
|
then
|
Report.Failed ("Incorrect duplication of files");
|
Report.Failed ("Incorrect duplication of files");
|
end if;
|
end if;
|
|
|
Menu.Delete (Backup_Copy);
|
Menu.Delete (Backup_Copy);
|
|
|
exception
|
exception
|
when CA11003_0.File_Data_Error =>
|
when CA11003_0.File_Data_Error =>
|
Report.Failed ("Exception raised during file validation");
|
Report.Failed ("Exception raised during file validation");
|
when CA11003_0.CA11003_1.File_Duplication_Error =>
|
when CA11003_0.CA11003_1.File_Duplication_Error =>
|
Report.Failed ("Exception raised during file duplication");
|
Report.Failed ("Exception raised during file duplication");
|
when others =>
|
when others =>
|
Report.Failed ("Unexpected exception in test procedure");
|
Report.Failed ("Unexpected exception in test procedure");
|
|
|
end File_Processing;
|
end File_Processing;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end CA11003;
|
end CA11003;
|
|
|