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/] [cb/] [cb20003.a] - Diff between revs 294 and 338

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

Rev 294 Rev 338
-- CB20003.A
-- CB20003.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 exceptions can be raised, reraised, and handled in an
--      Check that exceptions can be raised, reraised, and handled in an
--      accessed subprogram.
--      accessed subprogram.
--
--
--
--
-- TEST DESCRIPTION:
-- TEST DESCRIPTION:
--      Declare a record type, with one component being an access to
--      Declare a record type, with one component being an access to
--      subprogram type.  Various subprograms are defined to fit the profile
--      subprogram type.  Various subprograms are defined to fit the profile
--      of this access type, such that the record component can refer to
--      of this access type, such that the record component can refer to
--      any of the subprograms.
--      any of the subprograms.
--
--
--      Each of the subprograms raises a different exception, based on the
--      Each of the subprograms raises a different exception, based on the
--      value of an input parameter.  Exceptions are 1) raised, handled with
--      value of an input parameter.  Exceptions are 1) raised, handled with
--      an others handler, reraised and propagated to main to be handled in
--      an others handler, reraised and propagated to main to be handled in
--      a specific handler; 2) raised, handled in a specific handler, reraised
--      a specific handler; 2) raised, handled in a specific handler, reraised
--      and propagated to the main to be handled in an others handler there,
--      and propagated to the main to be handled in an others handler there,
--      and 3) raised and propagated directly to the caller by the subprogram.
--      and 3) raised and propagated directly to the caller by the subprogram.
--
--
--      Boolean variables are set throughout the test to ensure that correct
--      Boolean variables are set throughout the test to ensure that correct
--      exception processing has occurred, and these variables are verified at
--      exception processing has occurred, and these variables are verified at
--      the conclusion of the test.
--      the conclusion of the test.
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      06 Dec 94   SAIC    ACVC 2.0
--
--
--!
--!
package CB20003_0 is                          -- package Push_Buttons
package CB20003_0 is                          -- package Push_Buttons
   Non_Default_Priority,
   Non_Default_Priority,
   Non_Alert_Priority,
   Non_Alert_Priority,
   Non_Emergency_Priority : exception;
   Non_Emergency_Priority : exception;
   Handled_With_Others,
   Handled_With_Others,
   Reraised_In_Subprogram,
   Reraised_In_Subprogram,
   Handled_In_Caller      : Boolean := False;
   Handled_In_Caller      : Boolean := False;
   subtype Priority_Type is Integer range 1 .. 10;
   subtype Priority_Type is Integer range 1 .. 10;
   Default_Priority   : Priority_Type := 1;
   Default_Priority   : Priority_Type := 1;
   Alert_Priority     : Priority_Type := 3;
   Alert_Priority     : Priority_Type := 3;
   Emergency_Priority : Priority_Type := 5;
   Emergency_Priority : Priority_Type := 5;
   type Button is tagged private;                  -- Private tagged type.
   type Button is tagged private;                  -- Private tagged type.
   type Button_Response_Ptr is access procedure (P : in     Priority_Type;
   type Button_Response_Ptr is access procedure (P : in     Priority_Type;
                                                 B : in out Button);
                                                 B : in out Button);
   -- Procedures accessible with Button_Response_Ptr type.
   -- Procedures accessible with Button_Response_Ptr type.
   procedure Default_Response   (P : in     Priority_Type;
   procedure Default_Response   (P : in     Priority_Type;
                                 B : in out Button);
                                 B : in out Button);
   procedure Alert_Response     (P : in     Priority_Type;
   procedure Alert_Response     (P : in     Priority_Type;
                                 B : in out Button);
                                 B : in out Button);
   procedure Emergency_Response (P : in     Priority_Type;
   procedure Emergency_Response (P : in     Priority_Type;
                                 B : in out Button);
                                 B : in out Button);
   procedure Push (B : in out Button;
   procedure Push (B : in out Button;
                   P : in     Priority_Type);
                   P : in     Priority_Type);
   procedure Set_Response (B : in out Button;
   procedure Set_Response (B : in out Button;
                           R : in     Button_Response_Ptr);
                           R : in     Button_Response_Ptr);
private
private
   type Button is tagged
   type Button is tagged
      record
      record
         Priority :  Priority_Type       := Default_Priority;
         Priority :  Priority_Type       := Default_Priority;
         Response :  Button_Response_Ptr := Default_Response'Access;
         Response :  Button_Response_Ptr := Default_Response'Access;
      end record;
      end record;
end CB20003_0;                                -- package Push_Buttons
end CB20003_0;                                -- package Push_Buttons
     --=================================================================--
     --=================================================================--
with Report;
with Report;
package body CB20003_0 is                     -- package Push_Buttons
package body CB20003_0 is                     -- package Push_Buttons
   procedure Push (B : in out Button;
   procedure Push (B : in out Button;
                   P : in     Priority_Type) is
                   P : in     Priority_Type) is
   begin                                  -- Invoking subprogram designated
   begin                                  -- Invoking subprogram designated
      B.Response (P, B);                  -- by access value.
      B.Response (P, B);                  -- by access value.
   end Push;
   end Push;
   procedure Set_Response (B : in out Button;
   procedure Set_Response (B : in out Button;
                           R : in     Button_Response_Ptr) is
                           R : in     Button_Response_Ptr) is
   begin
   begin
      B.Response := R;      -- Set procedure value in record
      B.Response := R;      -- Set procedure value in record
   end Set_Response;
   end Set_Response;
   procedure Default_Response (P : in     Priority_Type;
   procedure Default_Response (P : in     Priority_Type;
                               B : in out Button) is
                               B : in out Button) is
   begin
   begin
      if (P > Default_Priority) then
      if (P > Default_Priority) then
         raise Non_Default_Priority;
         raise Non_Default_Priority;
         Report.Failed ("Exception not raised in procedure body");
         Report.Failed ("Exception not raised in procedure body");
      else
      else
         B.Priority := P;
         B.Priority := P;
      end if;
      end if;
   exception
   exception
      when others =>                    -- Catch exception with others handler
      when others =>                    -- Catch exception with others handler
         Handled_With_Others := True;   -- Successfully caught with "others"
         Handled_With_Others := True;   -- Successfully caught with "others"
         raise;
         raise;
         Report.Failed ("Exception not reraised in handler");
         Report.Failed ("Exception not reraised in handler");
   end Default_Response;
   end Default_Response;
   procedure Alert_Response (P : in     Priority_Type;
   procedure Alert_Response (P : in     Priority_Type;
                             B : in out Button) is
                             B : in out Button) is
   begin
   begin
      if (P > Alert_Priority) then
      if (P > Alert_Priority) then
         raise Non_Alert_Priority;
         raise Non_Alert_Priority;
         Report.Failed ("Exception not raised in procedure body");
         Report.Failed ("Exception not raised in procedure body");
      else
      else
         B.Priority := P;
         B.Priority := P;
      end if;
      end if;
   exception
   exception
      when Non_Alert_Priority =>
      when Non_Alert_Priority =>
         Reraised_In_Subprogram := True;
         Reraised_In_Subprogram := True;
         raise;                                  -- Propagate to caller.
         raise;                                  -- Propagate to caller.
         Report.Failed ("Exception not reraised in procedure excpt handler");
         Report.Failed ("Exception not reraised in procedure excpt handler");
      when others =>
      when others =>
         Report.Failed ("Incorrect exception raised/handled");
         Report.Failed ("Incorrect exception raised/handled");
   end Alert_Response;
   end Alert_Response;
   procedure Emergency_Response (P : in     Priority_type;
   procedure Emergency_Response (P : in     Priority_type;
                                 B : in out Button) is
                                 B : in out Button) is
   begin
   begin
      if (P > Emergency_Priority) then
      if (P > Emergency_Priority) then
         raise Non_Emergency_Priority;
         raise Non_Emergency_Priority;
         Report.Failed ("Exception not raised in procedure body");
         Report.Failed ("Exception not raised in procedure body");
      else
      else
         B.Priority := P;
         B.Priority := P;
      end if;
      end if;
      -- No exception handler here, exception will be propagated to caller.
      -- No exception handler here, exception will be propagated to caller.
   end Emergency_Response;
   end Emergency_Response;
end CB20003_0;                                -- package Push_Buttons
end CB20003_0;                                -- package Push_Buttons
     --=================================================================--
     --=================================================================--
with Report;
with Report;
with CB20003_0;                               -- package Push_Buttons
with CB20003_0;                               -- package Push_Buttons
procedure CB20003 is
procedure CB20003 is
   package Push_Buttons renames CB20003_0;
   package Push_Buttons renames CB20003_0;
   Console_Button : Push_Buttons.Button;
   Console_Button : Push_Buttons.Button;
begin
begin
   Report.Test ("CB20003", "Check that exceptions can be raised, "  &
   Report.Test ("CB20003", "Check that exceptions can be raised, "  &
                           "reraised, and handled in a subprogram " &
                           "reraised, and handled in a subprogram " &
                           "referenced by an access to subprogram value");
                           "referenced by an access to subprogram value");
   Default_Response_Processing:                 -- The exception
   Default_Response_Processing:                 -- The exception
                                                -- Handled_With_Others is to
                                                -- Handled_With_Others is to
                                                -- be caught with an others
                                                -- be caught with an others
                                                -- handler in Default_Resp.,
                                                -- handler in Default_Resp.,
                                                -- reraised, and handled with
                                                -- reraised, and handled with
                                                -- a specific handler here.
                                                -- a specific handler here.
   begin
   begin
      Push_Buttons.Push (Console_Button,        -- Raise exception that will
      Push_Buttons.Push (Console_Button,        -- Raise exception that will
                         Report.Ident_Int(2));  -- be handled in procedure.
                         Report.Ident_Int(2));  -- be handled in procedure.
   exception
   exception
      when Push_Buttons.Non_Default_Priority =>
      when Push_Buttons.Non_Default_Priority =>
         if not Push_Buttons.Handled_With_Others then   -- Not reraised in
         if not Push_Buttons.Handled_With_Others then   -- Not reraised in
                                                        -- procedure.
                                                        -- procedure.
            Report.Failed
            Report.Failed
              ("Exception not handled/reraised in procedure");
              ("Exception not handled/reraised in procedure");
         end if;
         end if;
      when others =>
      when others =>
         Report.Failed ("Exception handled in " &
         Report.Failed ("Exception handled in " &
                        " Default_Response_Processing block");
                        " Default_Response_Processing block");
   end Default_Response_Processing;
   end Default_Response_Processing;
   Alert_Response_Processing:
   Alert_Response_Processing:
   begin
   begin
      Push_Buttons.Set_Response (Console_Button,
      Push_Buttons.Set_Response (Console_Button,
                                 Push_Buttons.Alert_Response'access);
                                 Push_Buttons.Alert_Response'access);
      Push_Buttons.Push (Console_Button,        -- Raise exception that will
      Push_Buttons.Push (Console_Button,        -- Raise exception that will
                         Report.Ident_Int(4));  -- be handled in procedure,
                         Report.Ident_Int(4));  -- be handled in procedure,
                                                -- reraised, and propagated
                                                -- reraised, and propagated
                                                -- to caller.
                                                -- to caller.
      Report.Failed ("Exception not propagated to caller " &
      Report.Failed ("Exception not propagated to caller " &
                     "in Alert_Response_Processing block");
                     "in Alert_Response_Processing block");
   exception
   exception
      when Push_Buttons.Non_Alert_Priority =>
      when Push_Buttons.Non_Alert_Priority =>
         if not Push_Buttons.Reraised_In_Subprogram then  -- Not reraised in
         if not Push_Buttons.Reraised_In_Subprogram then  -- Not reraised in
                                                          -- procedure.
                                                          -- procedure.
            Report.Failed ("Exception not reraised in procedure");
            Report.Failed ("Exception not reraised in procedure");
         end if;
         end if;
      when others =>
      when others =>
         Report.Failed ("Exception handled in " &
         Report.Failed ("Exception handled in " &
                        " Alert_Response_Processing block");
                        " Alert_Response_Processing block");
   end Alert_Response_Processing;
   end Alert_Response_Processing;
   Emergency_Response_Processing:
   Emergency_Response_Processing:
   begin
   begin
      Push_Buttons.Set_Response (Console_Button,
      Push_Buttons.Set_Response (Console_Button,
                                 Push_Buttons.Emergency_Response'access);
                                 Push_Buttons.Emergency_Response'access);
      Push_Buttons.Push (Console_Button,        -- Raise exception that will
      Push_Buttons.Push (Console_Button,        -- Raise exception that will
                         Report.Ident_Int(6));  -- be propagated directly to
                         Report.Ident_Int(6));  -- be propagated directly to
                                                -- caller.
                                                -- caller.
      Report.Failed ("Exception not propagated to caller " &
      Report.Failed ("Exception not propagated to caller " &
                     "in Emergency_Response_Processing block");
                     "in Emergency_Response_Processing block");
   exception
   exception
      when Push_Buttons.Non_Emergency_Priority =>
      when Push_Buttons.Non_Emergency_Priority =>
         Push_Buttons.Handled_In_Caller := True;
         Push_Buttons.Handled_In_Caller := True;
      when others =>
      when others =>
         Report.Failed ("Exception handled in " &
         Report.Failed ("Exception handled in " &
                        " Emergency_Response_Processing block");
                        " Emergency_Response_Processing block");
   end Emergency_Response_Processing;
   end Emergency_Response_Processing;
   if not (Push_Buttons.Handled_With_Others and
   if not (Push_Buttons.Handled_With_Others and
           Push_Buttons.Reraised_In_Subprogram and
           Push_Buttons.Reraised_In_Subprogram and
           Push_Buttons.Handled_In_Caller )
           Push_Buttons.Handled_In_Caller )
   then
   then
      Report.Failed ("Incorrect exception handling in referenced subprograms");
      Report.Failed ("Incorrect exception handling in referenced subprograms");
   end if;
   end if;
   Report.Result;
   Report.Result;
end CB20003;
end CB20003;
 
 

powered by: WebSVN 2.1.0

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