OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxa9002.a] - Diff between revs 294 and 338

Only display areas with differences | Details | Blame | View Log

Rev 294 Rev 338
-- CXA9002.A
-- CXA9002.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 the operations defined in the generic package
--      Check that the operations defined in the generic package
--      Ada.Storage_IO provide the ability to store and retrieve objects
--      Ada.Storage_IO provide the ability to store and retrieve objects
--      of tagged types from in-memory buffers.
--      of tagged types from in-memory buffers.
--
--
-- TEST DESCRIPTION:
-- TEST DESCRIPTION:
--      The following scenario demonstrates how objects of a tagged type,
--      The following scenario demonstrates how objects of a tagged type,
--      extended types, and twice extended types can be written/read
--      extended types, and twice extended types can be written/read
--      to/from Direct_IO files. The Storage_IO subprograms, Read and Write,
--      to/from Direct_IO files. The Storage_IO subprograms, Read and Write,
--      demonstrated in this scenario, perform tag "fixing" prior to/following
--      demonstrated in this scenario, perform tag "fixing" prior to/following
--      transfer to the Direct_IO files.
--      transfer to the Direct_IO files.
--      This method is especially important for those implementations that
--      This method is especially important for those implementations that
--      represent tags as pointers, or for cases where the tagged objects
--      represent tags as pointers, or for cases where the tagged objects
--      are read in by a program other than the one that wrote them.
--      are read in by a program other than the one that wrote them.
--
--
--      In this small example, we have attempted to simulate the situation
--      In this small example, we have attempted to simulate the situation
--      where two independent programs are using a series of Direct_IO files,
--      where two independent programs are using a series of Direct_IO files,
--      one writing data to the files, and the second program reading the
--      one writing data to the files, and the second program reading the
--      data from those files.  Two procedures are defined, the first
--      data from those files.  Two procedures are defined, the first
--      simulating the program responsible for writing, the second simulating
--      simulating the program responsible for writing, the second simulating
--      a separate program opening and reading the data from the files.
--      a separate program opening and reading the data from the files.
--
--
--      The hierarchy of types used in this test can be displayed as follows:
--      The hierarchy of types used in this test can be displayed as follows:
--
--
--                                Account_Type
--                                Account_Type
--                                 /       \
--                                 /       \
--                                /         \
--                                /         \
--                               /           \
--                               /           \
--                  Cash_Account_Type       Investment_Account_Type
--                  Cash_Account_Type       Investment_Account_Type
--                     /         \
--                     /         \
--                    /           \
--                    /           \
--                   /             \
--                   /             \
--      Checking_Account_Type    Savings_Account_Type
--      Checking_Account_Type    Savings_Account_Type
--
--
-- APPLICABILITY CRITERIA:
-- APPLICABILITY CRITERIA:
--      Applicable to implementations capable of supporting external
--      Applicable to implementations capable of supporting external
--      Direct_IO files.
--      Direct_IO files.
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      06 Dec 94   SAIC    ACVC 2.0
--      08 Nov 95   SAIC    Corrected incorrect prefix of 'Tag for ACVC 2.0.1,
--      08 Nov 95   SAIC    Corrected incorrect prefix of 'Tag for ACVC 2.0.1,
--                          and mode of files in Procedure Read_Data.
--                          and mode of files in Procedure Read_Data.
--                          Added verification of objects reconstructed from
--                          Added verification of objects reconstructed from
--                          files.
--                          files.
--      27 Feb 97   PWB.CTA Allowed for non-support of some IO operations
--      27 Feb 97   PWB.CTA Allowed for non-support of some IO operations
--!
--!
package CXA9002_0 is
package CXA9002_0 is
   type Investment_Type is (Stocks, Bonds, Mutual_Funds);
   type Investment_Type is (Stocks, Bonds, Mutual_Funds);
   type Savings_Type    is (Standard, Business, Impound);
   type Savings_Type    is (Standard, Business, Impound);
   type Account_Type is tagged
   type Account_Type is tagged
      record
      record
         Num : String (1..3);
         Num : String (1..3);
      end record;
      end record;
   type Cash_Account_Type is new Account_Type with
   type Cash_Account_Type is new Account_Type with
      record
      record
         Years_As_Customer : Natural := 1;
         Years_As_Customer : Natural := 1;
      end record;
      end record;
   type Investment_Account_Type is new Account_Type with
   type Investment_Account_Type is new Account_Type with
      record
      record
         Investment_Vehicle : Investment_Type := Stocks;
         Investment_Vehicle : Investment_Type := Stocks;
      end record;
      end record;
   type Checking_Account_Type is new Cash_Account_Type with
   type Checking_Account_Type is new Cash_Account_Type with
      record
      record
         Checks_Per_Year  : Positive := 200;
         Checks_Per_Year  : Positive := 200;
         Interest_Bearing : Boolean  := False;
         Interest_Bearing : Boolean  := False;
      end record;
      end record;
   type Savings_Account_Type is new Cash_Account_Type with
   type Savings_Account_Type is new Cash_Account_Type with
      record
      record
         Kind : Savings_Type := Standard;
         Kind : Savings_Type := Standard;
      end record;
      end record;
end CXA9002_0;
end CXA9002_0;
---
---
with Report;
with Report;
with Ada.Storage_IO;
with Ada.Storage_IO;
with Ada.Direct_IO;
with Ada.Direct_IO;
with Ada.Tags;
with Ada.Tags;
with CXA9002_0;
with CXA9002_0;
procedure CXA9002 is
procedure CXA9002 is
   package Dir_IO is new Ada.Direct_IO (Integer);
   package Dir_IO is new Ada.Direct_IO (Integer);
   Test_File : Dir_IO.File_Type;
   Test_File : Dir_IO.File_Type;
   Incomplete : exception;
   Incomplete : exception;
begin
begin
   Report.Test ("CXA9002", "Check that the operations defined in the "   &
   Report.Test ("CXA9002", "Check that the operations defined in the "   &
                           "generic package Ada.Storage_IO provide the " &
                           "generic package Ada.Storage_IO provide the " &
                           "ability to store and retrieve objects of "   &
                           "ability to store and retrieve objects of "   &
                           "tagged types from in-memory buffers");
                           "tagged types from in-memory buffers");
   Test_For_Direct_IO_Support:
   Test_For_Direct_IO_Support:
   begin
   begin
      -- The following Create does not have any bearing on the test scenario,
      -- The following Create does not have any bearing on the test scenario,
      -- but is included to check that the implementation supports Direct_IO
      -- but is included to check that the implementation supports Direct_IO
      -- files.  An exception on this Create statement will raise a Name_Error
      -- files.  An exception on this Create statement will raise a Name_Error
      -- or Use_Error, which will be handled to produce a Not_Applicable
      -- or Use_Error, which will be handled to produce a Not_Applicable
      -- result. If created, the file is immediately deleted, as it is not
      -- result. If created, the file is immediately deleted, as it is not
      -- needed for the program scenario.
      -- needed for the program scenario.
      Dir_IO.Create (Test_File,
      Dir_IO.Create (Test_File,
                     Dir_IO.Out_File,
                     Dir_IO.Out_File,
                     Report.Legal_File_Name(1));
                     Report.Legal_File_Name(1));
   exception
   exception
       when Dir_IO.Use_Error | Dir_IO.Name_Error =>
       when Dir_IO.Use_Error | Dir_IO.Name_Error =>
          Report.Not_Applicable
          Report.Not_Applicable
             ( "Files not supported - Create as Out_File for Direct_IO" );
             ( "Files not supported - Create as Out_File for Direct_IO" );
          raise Incomplete;
          raise Incomplete;
   end Test_for_Direct_IO_Support;
   end Test_for_Direct_IO_Support;
   Deletion:
   Deletion:
   begin
   begin
      Dir_IO.Delete (Test_File);
      Dir_IO.Delete (Test_File);
   exception
   exception
      when others =>
      when others =>
         Report.Failed
         Report.Failed
            ( "Delete not properly implemented for Direct_IO" );
            ( "Delete not properly implemented for Direct_IO" );
   end Deletion;
   end Deletion;
   Test_Block:
   Test_Block:
   declare
   declare
      use CXA9002_0;
      use CXA9002_0;
      Acct_Filename : constant String := Report.Legal_File_Name(1);
      Acct_Filename : constant String := Report.Legal_File_Name(1);
      Cash_Filename : constant String := Report.Legal_File_Name(2);
      Cash_Filename : constant String := Report.Legal_File_Name(2);
      Inv_Filename  : constant String := Report.Legal_File_Name(3);
      Inv_Filename  : constant String := Report.Legal_File_Name(3);
      Chk_Filename  : constant String := Report.Legal_File_Name(4);
      Chk_Filename  : constant String := Report.Legal_File_Name(4);
      Sav_Filename  : constant String := Report.Legal_File_Name(5);
      Sav_Filename  : constant String := Report.Legal_File_Name(5);
      type Tag_Pointer_Type is access String;
      type Tag_Pointer_Type is access String;
      TC_Account_Type_Tag,
      TC_Account_Type_Tag,
      TC_Cash_Account_Type_Tag,
      TC_Cash_Account_Type_Tag,
      TC_Investment_Account_Type_Tag,
      TC_Investment_Account_Type_Tag,
      TC_Checking_Account_Type_Tag,
      TC_Checking_Account_Type_Tag,
      TC_Savings_Account_Type_Tag    : Tag_Pointer_Type;
      TC_Savings_Account_Type_Tag    : Tag_Pointer_Type;
      TC_Account            : Account_Type            :=
      TC_Account            : Account_Type            :=
                                (Num => "123");
                                (Num => "123");
      TC_Cash_Account       : Cash_Account_Type       :=
      TC_Cash_Account       : Cash_Account_Type       :=
                                (Num               => "234",
                                (Num               => "234",
                                 Years_As_Customer => 3);
                                 Years_As_Customer => 3);
      TC_Investment_Account : Investment_Account_Type :=
      TC_Investment_Account : Investment_Account_Type :=
                                (Num                => "456",
                                (Num                => "456",
                                 Investment_Vehicle => Bonds);
                                 Investment_Vehicle => Bonds);
      TC_Checking_Account   : Checking_Account_Type   :=
      TC_Checking_Account   : Checking_Account_Type   :=
                                (Num               => "567",
                                (Num               => "567",
                                 Years_As_Customer => 2,
                                 Years_As_Customer => 2,
                                 Checks_Per_Year   => 300,
                                 Checks_Per_Year   => 300,
                                 Interest_Bearing  => True);
                                 Interest_Bearing  => True);
      TC_Savings_Account    : Savings_Account_Type    :=
      TC_Savings_Account    : Savings_Account_Type    :=
                                (Num               => "789",
                                (Num               => "789",
                                 Years_As_Customer => 14,
                                 Years_As_Customer => 14,
                                 Kind              => Business);
                                 Kind              => Business);
      procedure Buffer_Data is
      procedure Buffer_Data is
         Account            : Account_Type            :=
         Account            : Account_Type            :=
                                TC_Account;
                                TC_Account;
         Cash_Account       : Cash_Account_Type       :=
         Cash_Account       : Cash_Account_Type       :=
                                TC_Cash_Account;
                                TC_Cash_Account;
         Investment_Account : Investment_Account_Type :=
         Investment_Account : Investment_Account_Type :=
                                TC_Investment_Account;
                                TC_Investment_Account;
         Checking_Account   : Checking_Account_Type   :=
         Checking_Account   : Checking_Account_Type   :=
                                TC_Checking_Account;
                                TC_Checking_Account;
         Savings_Account    : Savings_Account_Type    :=
         Savings_Account    : Savings_Account_Type    :=
                                TC_Savings_Account;
                                TC_Savings_Account;
         -- The instantiations below are a central point in this test.
         -- The instantiations below are a central point in this test.
         -- Storage_IO is instantiated for each of the specific tagged
         -- Storage_IO is instantiated for each of the specific tagged
         -- type. These instantiated packages will be used to compress
         -- type. These instantiated packages will be used to compress
         -- tagged objects of these various types into buffers that will
         -- tagged objects of these various types into buffers that will
         -- be written to the Direct_IO files declared below.
         -- be written to the Direct_IO files declared below.
         package Acct_SIO is new Ada.Storage_IO (Account_Type);
         package Acct_SIO is new Ada.Storage_IO (Account_Type);
         package Cash_SIO is new Ada.Storage_IO (Cash_Account_Type);
         package Cash_SIO is new Ada.Storage_IO (Cash_Account_Type);
         package Inv_SIO  is new Ada.Storage_IO (Investment_Account_Type);
         package Inv_SIO  is new Ada.Storage_IO (Investment_Account_Type);
         package Chk_SIO  is new Ada.Storage_IO (Checking_Account_Type);
         package Chk_SIO  is new Ada.Storage_IO (Checking_Account_Type);
         package Sav_SIO  is new Ada.Storage_IO (Savings_Account_Type);
         package Sav_SIO  is new Ada.Storage_IO (Savings_Account_Type);
         -- Direct_IO is instantiated for the buffer types defined in the
         -- Direct_IO is instantiated for the buffer types defined in the
         -- instantiated Storage_IO packages.
         -- instantiated Storage_IO packages.
         package Acct_DIO is new Ada.Direct_IO (Acct_SIO.Buffer_Type);
         package Acct_DIO is new Ada.Direct_IO (Acct_SIO.Buffer_Type);
         package Cash_DIO is new Ada.Direct_IO (Cash_SIO.Buffer_Type);
         package Cash_DIO is new Ada.Direct_IO (Cash_SIO.Buffer_Type);
         package Inv_DIO  is new Ada.Direct_IO (Inv_SIO.Buffer_Type);
         package Inv_DIO  is new Ada.Direct_IO (Inv_SIO.Buffer_Type);
         package Chk_DIO  is new Ada.Direct_IO (Chk_SIO.Buffer_Type);
         package Chk_DIO  is new Ada.Direct_IO (Chk_SIO.Buffer_Type);
         package Sav_DIO  is new Ada.Direct_IO (Sav_SIO.Buffer_Type);
         package Sav_DIO  is new Ada.Direct_IO (Sav_SIO.Buffer_Type);
         Acct_Buffer : Acct_SIO.Buffer_Type;
         Acct_Buffer : Acct_SIO.Buffer_Type;
         Cash_Buffer : Cash_SIO.Buffer_Type;
         Cash_Buffer : Cash_SIO.Buffer_Type;
         Inv_Buffer  : Inv_SIO.Buffer_Type;
         Inv_Buffer  : Inv_SIO.Buffer_Type;
         Chk_Buffer  : Chk_SIO.Buffer_Type;
         Chk_Buffer  : Chk_SIO.Buffer_Type;
         Sav_Buffer  : Sav_SIO.Buffer_Type;
         Sav_Buffer  : Sav_SIO.Buffer_Type;
         Acct_File   : Acct_DIO.File_Type;
         Acct_File   : Acct_DIO.File_Type;
         Cash_File   : Cash_DIO.File_Type;
         Cash_File   : Cash_DIO.File_Type;
         Inv_File    : Inv_DIO.File_Type;
         Inv_File    : Inv_DIO.File_Type;
         Chk_File    : Chk_DIO.File_Type;
         Chk_File    : Chk_DIO.File_Type;
         Sav_File    : Sav_DIO.File_Type;
         Sav_File    : Sav_DIO.File_Type;
      begin
      begin
         Acct_DIO.Create (Acct_File, Acct_DIO.Out_File, Acct_Filename);
         Acct_DIO.Create (Acct_File, Acct_DIO.Out_File, Acct_Filename);
         Cash_DIO.Create (Cash_File, Cash_DIO.Out_File, Cash_Filename);
         Cash_DIO.Create (Cash_File, Cash_DIO.Out_File, Cash_Filename);
         Inv_DIO.Create  (Inv_File,  Inv_DIO.Out_File,  Inv_Filename);
         Inv_DIO.Create  (Inv_File,  Inv_DIO.Out_File,  Inv_Filename);
         Chk_DIO.Create  (Chk_File,  Chk_DIO.Out_File,  Chk_Filename);
         Chk_DIO.Create  (Chk_File,  Chk_DIO.Out_File,  Chk_Filename);
         Sav_DIO.Create  (Sav_File,  Sav_DIO.Out_File,  Sav_Filename);
         Sav_DIO.Create  (Sav_File,  Sav_DIO.Out_File,  Sav_Filename);
         -- Store the tag values of the objects declared above for
         -- Store the tag values of the objects declared above for
         -- comparison with tag values of objects following processing.
         -- comparison with tag values of objects following processing.
         TC_Account_Type_Tag :=
         TC_Account_Type_Tag :=
           new String'(Ada.Tags.External_Tag(Account_Type'Tag));
           new String'(Ada.Tags.External_Tag(Account_Type'Tag));
         TC_Cash_Account_Type_Tag :=
         TC_Cash_Account_Type_Tag :=
           new String'(Ada.Tags.External_Tag(Cash_Account_Type'Tag));
           new String'(Ada.Tags.External_Tag(Cash_Account_Type'Tag));
         TC_Investment_Account_Type_Tag :=
         TC_Investment_Account_Type_Tag :=
           new String'(Ada.Tags.External_Tag(Investment_Account_Type'Tag));
           new String'(Ada.Tags.External_Tag(Investment_Account_Type'Tag));
         TC_Checking_Account_Type_Tag :=
         TC_Checking_Account_Type_Tag :=
           new String'(Ada.Tags.External_Tag(Checking_Account_Type'Tag));
           new String'(Ada.Tags.External_Tag(Checking_Account_Type'Tag));
         TC_Savings_Account_Type_Tag :=
         TC_Savings_Account_Type_Tag :=
           new String'(Ada.Tags.External_Tag(Savings_Account_Type'Tag));
           new String'(Ada.Tags.External_Tag(Savings_Account_Type'Tag));
         -- Prepare tagged data for writing to the Direct_IO files using
         -- Prepare tagged data for writing to the Direct_IO files using
         -- Storage_IO procedure to place data in buffers.
         -- Storage_IO procedure to place data in buffers.
         Acct_SIO.Write (Buffer => Acct_Buffer, Item => Account);
         Acct_SIO.Write (Buffer => Acct_Buffer, Item => Account);
         Cash_SIO.Write (Cash_Buffer, Cash_Account);
         Cash_SIO.Write (Cash_Buffer, Cash_Account);
         Inv_SIO.Write  (Inv_Buffer, Item => Investment_Account);
         Inv_SIO.Write  (Inv_Buffer, Item => Investment_Account);
         Chk_SIO.Write  (Buffer => Chk_Buffer, Item => Checking_Account);
         Chk_SIO.Write  (Buffer => Chk_Buffer, Item => Checking_Account);
         Sav_SIO.Write  (Sav_Buffer, Savings_Account);
         Sav_SIO.Write  (Sav_Buffer, Savings_Account);
         -- At this point, the data and associated tag values have been
         -- At this point, the data and associated tag values have been
         -- buffered by the Storage_IO procedure, and the buffered data
         -- buffered by the Storage_IO procedure, and the buffered data
         -- can be written to the appropriate Direct_IO file.
         -- can be written to the appropriate Direct_IO file.
         Acct_DIO.Write (File => Acct_File, Item => Acct_Buffer);
         Acct_DIO.Write (File => Acct_File, Item => Acct_Buffer);
         Cash_DIO.Write (Cash_File, Cash_Buffer);
         Cash_DIO.Write (Cash_File, Cash_Buffer);
         Inv_DIO.Write  (Inv_File, Item => Inv_Buffer);
         Inv_DIO.Write  (Inv_File, Item => Inv_Buffer);
         Chk_DIO.Write  (File => Chk_File, Item =>Chk_Buffer);
         Chk_DIO.Write  (File => Chk_File, Item =>Chk_Buffer);
         Sav_DIO.Write  (Sav_File, Sav_Buffer);
         Sav_DIO.Write  (Sav_File, Sav_Buffer);
         -- Close all Direct_IO files.
         -- Close all Direct_IO files.
         Acct_DIO.Close (Acct_File);
         Acct_DIO.Close (Acct_File);
         Cash_DIO.Close (Cash_File);
         Cash_DIO.Close (Cash_File);
         Inv_DIO.Close  (Inv_File);
         Inv_DIO.Close  (Inv_File);
         Chk_DIO.Close  (Chk_File);
         Chk_DIO.Close  (Chk_File);
         Sav_DIO.Close  (Sav_File);
         Sav_DIO.Close  (Sav_File);
      exception
      exception
         when others => Report.Failed("Exception raised in Buffer_Data");
         when others => Report.Failed("Exception raised in Buffer_Data");
      end Buffer_Data;
      end Buffer_Data;
      procedure Read_Data is
      procedure Read_Data is
         Account            : Account_Type;
         Account            : Account_Type;
         Cash_Account       : Cash_Account_Type;
         Cash_Account       : Cash_Account_Type;
         Investment_Account : Investment_Account_Type;
         Investment_Account : Investment_Account_Type;
         Checking_Account   : Checking_Account_Type;
         Checking_Account   : Checking_Account_Type;
         Savings_Account    : Savings_Account_Type;
         Savings_Account    : Savings_Account_Type;
         -- Storage_IO is instantiated for each of the specific tagged
         -- Storage_IO is instantiated for each of the specific tagged
         -- type.
         -- type.
         package Acct_SIO is new Ada.Storage_IO (Account_Type);
         package Acct_SIO is new Ada.Storage_IO (Account_Type);
         package Cash_SIO is new Ada.Storage_IO (Cash_Account_Type);
         package Cash_SIO is new Ada.Storage_IO (Cash_Account_Type);
         package Inv_SIO  is new Ada.Storage_IO (Investment_Account_Type);
         package Inv_SIO  is new Ada.Storage_IO (Investment_Account_Type);
         package Chk_SIO  is new Ada.Storage_IO (Checking_Account_Type);
         package Chk_SIO  is new Ada.Storage_IO (Checking_Account_Type);
         package Sav_SIO  is new Ada.Storage_IO (Savings_Account_Type);
         package Sav_SIO  is new Ada.Storage_IO (Savings_Account_Type);
         -- Direct_IO is instantiated for the buffer types defined in the
         -- Direct_IO is instantiated for the buffer types defined in the
         -- instantiated Storage_IO packages.
         -- instantiated Storage_IO packages.
         package Acct_DIO is new Ada.Direct_IO (Acct_SIO.Buffer_Type);
         package Acct_DIO is new Ada.Direct_IO (Acct_SIO.Buffer_Type);
         package Cash_DIO is new Ada.Direct_IO (Cash_SIO.Buffer_Type);
         package Cash_DIO is new Ada.Direct_IO (Cash_SIO.Buffer_Type);
         package Inv_DIO  is new Ada.Direct_IO (Inv_SIO.Buffer_Type);
         package Inv_DIO  is new Ada.Direct_IO (Inv_SIO.Buffer_Type);
         package Chk_DIO  is new Ada.Direct_IO (Chk_SIO.Buffer_Type);
         package Chk_DIO  is new Ada.Direct_IO (Chk_SIO.Buffer_Type);
         package Sav_DIO  is new Ada.Direct_IO (Sav_SIO.Buffer_Type);
         package Sav_DIO  is new Ada.Direct_IO (Sav_SIO.Buffer_Type);
         Acct_Buffer : Acct_SIO.Buffer_Type;
         Acct_Buffer : Acct_SIO.Buffer_Type;
         Cash_Buffer : Cash_SIO.Buffer_Type;
         Cash_Buffer : Cash_SIO.Buffer_Type;
         Inv_Buffer  : Inv_SIO.Buffer_Type;
         Inv_Buffer  : Inv_SIO.Buffer_Type;
         Chk_Buffer  : Chk_SIO.Buffer_Type;
         Chk_Buffer  : Chk_SIO.Buffer_Type;
         Sav_Buffer  : Sav_SIO.Buffer_Type;
         Sav_Buffer  : Sav_SIO.Buffer_Type;
         Acct_File   : Acct_DIO.File_Type;
         Acct_File   : Acct_DIO.File_Type;
         Cash_File   : Cash_DIO.File_Type;
         Cash_File   : Cash_DIO.File_Type;
         Inv_File    : Inv_DIO.File_Type;
         Inv_File    : Inv_DIO.File_Type;
         Chk_File    : Chk_DIO.File_Type;
         Chk_File    : Chk_DIO.File_Type;
         Sav_File    : Sav_DIO.File_Type;
         Sav_File    : Sav_DIO.File_Type;
      begin
      begin
         -- Open the Direct_IO files.
         -- Open the Direct_IO files.
         Acct_DIO.Open (Acct_File, Acct_DIO.In_File, Acct_Filename);
         Acct_DIO.Open (Acct_File, Acct_DIO.In_File, Acct_Filename);
         Cash_DIO.Open (Cash_File, Cash_DIO.In_File, Cash_Filename);
         Cash_DIO.Open (Cash_File, Cash_DIO.In_File, Cash_Filename);
         Inv_DIO.Open  (Inv_File,  Inv_DIO.In_File,  Inv_Filename);
         Inv_DIO.Open  (Inv_File,  Inv_DIO.In_File,  Inv_Filename);
         Chk_DIO.Open  (Chk_File,  Chk_DIO.In_File,  Chk_Filename);
         Chk_DIO.Open  (Chk_File,  Chk_DIO.In_File,  Chk_Filename);
         Sav_DIO.Open  (Sav_File,  Sav_DIO.In_File,  Sav_Filename);
         Sav_DIO.Open  (Sav_File,  Sav_DIO.In_File,  Sav_Filename);
         -- Read the buffer data from the files using Direct_IO.
         -- Read the buffer data from the files using Direct_IO.
         Acct_DIO.Read (File => Acct_File, Item => Acct_Buffer);
         Acct_DIO.Read (File => Acct_File, Item => Acct_Buffer);
         Cash_DIO.Read (Cash_File, Cash_Buffer);
         Cash_DIO.Read (Cash_File, Cash_Buffer);
         Inv_DIO.Read  (Inv_File, Item => Inv_Buffer);
         Inv_DIO.Read  (Inv_File, Item => Inv_Buffer);
         Chk_DIO.Read  (File => Chk_File, Item =>Chk_Buffer);
         Chk_DIO.Read  (File => Chk_File, Item =>Chk_Buffer);
         Sav_DIO.Read  (Sav_File, Sav_Buffer);
         Sav_DIO.Read  (Sav_File, Sav_Buffer);
         -- At this point, the data and associated tag values are stored
         -- At this point, the data and associated tag values are stored
         -- in buffers. Use the Storage_IO procedure Read to recreate the
         -- in buffers. Use the Storage_IO procedure Read to recreate the
         -- tagged objects from the buffers.
         -- tagged objects from the buffers.
         Acct_SIO.Read (Buffer => Acct_Buffer, Item => Account);
         Acct_SIO.Read (Buffer => Acct_Buffer, Item => Account);
         Cash_SIO.Read (Cash_Buffer, Cash_Account);
         Cash_SIO.Read (Cash_Buffer, Cash_Account);
         Inv_SIO.Read  (Inv_Buffer, Item => Investment_Account);
         Inv_SIO.Read  (Inv_Buffer, Item => Investment_Account);
         Chk_SIO.Read  (Buffer => Chk_Buffer, Item => Checking_Account);
         Chk_SIO.Read  (Buffer => Chk_Buffer, Item => Checking_Account);
         Sav_SIO.Read  (Sav_Buffer, Savings_Account);
         Sav_SIO.Read  (Sav_Buffer, Savings_Account);
         -- Delete all Direct_IO files.
         -- Delete all Direct_IO files.
         Acct_DIO.Delete (Acct_File);
         Acct_DIO.Delete (Acct_File);
         Cash_DIO.Delete (Cash_File);
         Cash_DIO.Delete (Cash_File);
         Inv_DIO.Delete  (Inv_File);
         Inv_DIO.Delete  (Inv_File);
         Chk_DIO.Delete  (Chk_File);
         Chk_DIO.Delete  (Chk_File);
         Sav_DIO.Delete  (Sav_File);
         Sav_DIO.Delete  (Sav_File);
         Data_Verification_Block:
         Data_Verification_Block:
         begin
         begin
            if Account /= TC_Account then
            if Account /= TC_Account then
               Report.Failed("Incorrect Account object reconstructed");
               Report.Failed("Incorrect Account object reconstructed");
            end if;
            end if;
            if Cash_Account /= TC_Cash_Account then
            if Cash_Account /= TC_Cash_Account then
               Report.Failed
               Report.Failed
                 ("Incorrect Cash_Account object reconstructed");
                 ("Incorrect Cash_Account object reconstructed");
            end if;
            end if;
            if Investment_Account /= TC_Investment_Account then
            if Investment_Account /= TC_Investment_Account then
               Report.Failed
               Report.Failed
                 ("Incorrect Investment_Account object reconstructed");
                 ("Incorrect Investment_Account object reconstructed");
            end if;
            end if;
            if Checking_Account /= TC_Checking_Account then
            if Checking_Account /= TC_Checking_Account then
               Report.Failed
               Report.Failed
                 ("Incorrect Checking_Account object reconstructed");
                 ("Incorrect Checking_Account object reconstructed");
            end if;
            end if;
            if Savings_Account /= TC_Savings_Account then
            if Savings_Account /= TC_Savings_Account then
               Report.Failed
               Report.Failed
                 ("Incorrect Savings_Account object reconstructed");
                 ("Incorrect Savings_Account object reconstructed");
            end if;
            end if;
         exception
         exception
            when others =>
            when others =>
              Report.Failed
              Report.Failed
                ("Exception raised during Data_Verification Block");
                ("Exception raised during Data_Verification Block");
         end Data_Verification_Block;
         end Data_Verification_Block;
         -- To ensure that the tags of the values reconstructed by
         -- To ensure that the tags of the values reconstructed by
         -- Storage_IO were properly preserved, object tag values following
         -- Storage_IO were properly preserved, object tag values following
         -- object reconstruction are compared with tag values of objects
         -- object reconstruction are compared with tag values of objects
         -- stored prior to processing.
         -- stored prior to processing.
         Tag_Verification_Block:
         Tag_Verification_Block:
         begin
         begin
            if TC_Account_Type_Tag.all /=
            if TC_Account_Type_Tag.all /=
               Ada.Tags.External_Tag(Account_Type'Class(Account)'Tag)
               Ada.Tags.External_Tag(Account_Type'Class(Account)'Tag)
            then
            then
               Report.Failed("Incorrect Account tag");
               Report.Failed("Incorrect Account tag");
            end if;
            end if;
            if TC_Cash_Account_Type_Tag.all       /=
            if TC_Cash_Account_Type_Tag.all       /=
               Ada.Tags.External_Tag(
               Ada.Tags.External_Tag(
                 Cash_Account_Type'Class(Cash_Account)'Tag)
                 Cash_Account_Type'Class(Cash_Account)'Tag)
            then
            then
               Report.Failed("Incorrect Cash_Account tag");
               Report.Failed("Incorrect Cash_Account tag");
            end if;
            end if;
            if TC_Investment_Account_Type_Tag.all /=
            if TC_Investment_Account_Type_Tag.all /=
               Ada.Tags.External_Tag(
               Ada.Tags.External_Tag(
                 Investment_Account_Type'Class(Investment_Account)'Tag)
                 Investment_Account_Type'Class(Investment_Account)'Tag)
            then
            then
               Report.Failed("Incorrect Investment_Account tag");
               Report.Failed("Incorrect Investment_Account tag");
            end if;
            end if;
            if TC_Checking_Account_Type_Tag.all   /=
            if TC_Checking_Account_Type_Tag.all   /=
               Ada.Tags.External_Tag(
               Ada.Tags.External_Tag(
                 Checking_Account_Type'Class(Checking_Account)'Tag)
                 Checking_Account_Type'Class(Checking_Account)'Tag)
            then
            then
               Report.Failed("Incorrect Checking_Account tag");
               Report.Failed("Incorrect Checking_Account tag");
            end if;
            end if;
            if TC_Savings_Account_Type_Tag.all    /=
            if TC_Savings_Account_Type_Tag.all    /=
               Ada.Tags.External_Tag(
               Ada.Tags.External_Tag(
                 Savings_Account_Type'Class(Savings_Account)'Tag)
                 Savings_Account_Type'Class(Savings_Account)'Tag)
            then
            then
               Report.Failed("Incorrect Savings_Account tag");
               Report.Failed("Incorrect Savings_Account tag");
            end if;
            end if;
         exception
         exception
            when others =>
            when others =>
              Report.Failed ("Exception raised during tag evaluation");
              Report.Failed ("Exception raised during tag evaluation");
         end Tag_Verification_Block;
         end Tag_Verification_Block;
      exception
      exception
         when others => Report.Failed ("Exception in Read_Data");
         when others => Report.Failed ("Exception in Read_Data");
      end Read_Data;
      end Read_Data;
      begin  -- Test_Block
      begin  -- Test_Block
      -- Enter the data into the appropriate files.
      -- Enter the data into the appropriate files.
      Buffer_Data;
      Buffer_Data;
      -- Reconstruct the data from files, and verify the results.
      -- Reconstruct the data from files, and verify the results.
      Read_Data;
      Read_Data;
   exception
   exception
      when others => Report.Failed ("Exception raised in Test_Block");
      when others => Report.Failed ("Exception raised in Test_Block");
   end Test_Block;
   end Test_Block;
   Report.Result;
   Report.Result;
exception
exception
   when Incomplete =>
   when Incomplete =>
      Report.Result;
      Report.Result;
   when others     =>
   when others     =>
      Report.Failed ( "Unexpected exception" );
      Report.Failed ( "Unexpected exception" );
      Report.Result;
      Report.Result;
end CXA9002;
end CXA9002;
 
 

powered by: WebSVN 2.1.0

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