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

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

Rev 294 Rev 338
-- CD92001.A
-- CD92001.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 if X denotes a scalar object, X'Valid
--      Check that if X denotes a scalar object, X'Valid
--      yields true if an only if the object denoted by X is normal and
--      yields true if an only if the object denoted by X is normal and
--      has a valid representation.
--      has a valid representation.
--
--
-- TEST DESCRIPTION:
-- TEST DESCRIPTION:
--      Using Unchecked_Conversion, Image and Value attributes, combined
--      Using Unchecked_Conversion, Image and Value attributes, combined
--      with string manipulation, cause valid and invalid values to be
--      with string manipulation, cause valid and invalid values to be
--      stored in various objects.  Check their validity with the
--      stored in various objects.  Check their validity with the
--      attribute 'Valid.  Invalid objects are created in a loop which
--      attribute 'Valid.  Invalid objects are created in a loop which
--      performs a simplistic check to ensure that the values being used
--      performs a simplistic check to ensure that the values being used
--      are indeed not valid, then assigns the value using an instance of
--      are indeed not valid, then assigns the value using an instance of
--      Unchecked_Conversion.  The creation of the tables of valid values
--      Unchecked_Conversion.  The creation of the tables of valid values
--      is trivial.
--      is trivial.
--
--
-- APPLICABILITY CRITERIA:
-- APPLICABILITY CRITERIA:
--      All implementations must attempt to compile this test.
--      All implementations must attempt to compile this test.
--
--
--      For implementations validating against Systems Programming Annex (C):
--      For implementations validating against Systems Programming Annex (C):
--        this test must execute and report PASSED.
--        this test must execute and report PASSED.
--
--
--      For implementations not validating against Annex C:
--      For implementations not validating against Annex C:
--        this test may report compile time errors at one or more points
--        this test may report compile time errors at one or more points
--        indicated by "-- N/A => ERROR", in which case it may be graded as
--        indicated by "-- N/A => ERROR", in which case it may be graded as
--        inapplicable. Otherwise, the test must execute and report PASSED.
--        inapplicable. Otherwise, the test must execute and report PASSED.
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      10 MAY 95   SAIC    Initial version
--      10 MAY 95   SAIC    Initial version
--      07 MAY 96   SAIC    Changed U_C to Ada.U_C for 2.1
--      07 MAY 96   SAIC    Changed U_C to Ada.U_C for 2.1
--      05 JAN 99   RLB     Added Component_Size clauses to compensate
--      05 JAN 99   RLB     Added Component_Size clauses to compensate
--                          for the fact that there is no required size
--                          for the fact that there is no required size
--                          for either the enumeration or modular components.
--                          for either the enumeration or modular components.
--!
--!
with Report;
with Report;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Conversion;
with System;
with System;
procedure CD92001 is
procedure CD92001 is
  type Sparse_Enumerated is
  type Sparse_Enumerated is
       ( Help, Home, Page_Up, Del, EndK,
       ( Help, Home, Page_Up, Del, EndK,
         Page_Down, Up, Left, Down, Right );
         Page_Down, Up, Left, Down, Right );
  for Sparse_Enumerated use ( Help      =>    2,
  for Sparse_Enumerated use ( Help      =>    2,
                              Home      =>    4,
                              Home      =>    4,
                              Page_Up   =>    8,
                              Page_Up   =>    8,
                              Del       =>   16,
                              Del       =>   16,
                              EndK      =>   32,
                              EndK      =>   32,
                              Page_Down =>   64,
                              Page_Down =>   64,
                              Up        =>  128,
                              Up        =>  128,
                              Left      =>  256,
                              Left      =>  256,
                              Down      =>  512,
                              Down      =>  512,
                              Right     => 1024 );
                              Right     => 1024 );
  type Mod_10 is mod 10;
  type Mod_10 is mod 10;
  type Default_Enumerated is ( Zero,  One, Two,   Three, Four,
  type Default_Enumerated is ( Zero,  One, Two,   Three, Four,
                               Five,  Six, Seven, Eight, Nine,
                               Five,  Six, Seven, Eight, Nine,
                               Clear, '=', '/',   '*',   '-',
                               Clear, '=', '/',   '*',   '-',
                               '+',   Enter );
                               '+',   Enter );
    for Default_Enumerated'Size use 8;
    for Default_Enumerated'Size use 8;
  Default_Enumerated_Count : constant := 17;
  Default_Enumerated_Count : constant := 17;
  type Mod_By_Enum_Items is mod Default_Enumerated_Count;
  type Mod_By_Enum_Items is mod Default_Enumerated_Count;
  type Mod_Same_Size_As_Sparse_Enum is mod 2**12;
  type Mod_Same_Size_As_Sparse_Enum is mod 2**12;
                                        -- Sparse_Enumerated 'Size;
                                        -- Sparse_Enumerated 'Size;
  type Mod_Same_Size_As_Def_Enum is mod 2**8;
  type Mod_Same_Size_As_Def_Enum is mod 2**8;
                                     -- Default_Enumerated'Size;
                                     -- Default_Enumerated'Size;
  subtype Test_Width is Positive range 1..100;
  subtype Test_Width is Positive range 1..100;
  -- Note: There is no required relationship between 'Size and 'Component_Size,
  -- Note: There is no required relationship between 'Size and 'Component_Size,
  -- so we must use component_size clauses here.
  -- so we must use component_size clauses here.
  -- We use the following expressions to insure that the component size is a
  -- We use the following expressions to insure that the component size is a
  -- multiple of the Storage_Unit.
  -- multiple of the Storage_Unit.
  Sparse_Component_Size : constant := ((Sparse_Enumerated'Size / System.Storage_Unit) +
  Sparse_Component_Size : constant := ((Sparse_Enumerated'Size / System.Storage_Unit) +
        Boolean'Pos((Sparse_Enumerated'Size mod System.Storage_Unit) /= 0)) *
        Boolean'Pos((Sparse_Enumerated'Size mod System.Storage_Unit) /= 0)) *
        System.Storage_Unit;
        System.Storage_Unit;
  Default_Component_Size : constant := ((Default_Enumerated'Size / System.Storage_Unit) +
  Default_Component_Size : constant := ((Default_Enumerated'Size / System.Storage_Unit) +
        Boolean'Pos((Sparse_Enumerated'Size mod System.Storage_Unit) /= 0)) *
        Boolean'Pos((Sparse_Enumerated'Size mod System.Storage_Unit) /= 0)) *
        System.Storage_Unit;
        System.Storage_Unit;
  type Sparse_Enum_Table is array(Test_Width) of Sparse_Enumerated;
  type Sparse_Enum_Table is array(Test_Width) of Sparse_Enumerated;
  for Sparse_Enum_Table'Component_Size use Sparse_Component_Size;  -- N/A => ERROR.
  for Sparse_Enum_Table'Component_Size use Sparse_Component_Size;  -- N/A => ERROR.
  type Def_Enum_Table is array(Test_Width) of Default_Enumerated;
  type Def_Enum_Table is array(Test_Width) of Default_Enumerated;
  for Def_Enum_Table'Component_Size use Default_Component_Size;  -- N/A => ERROR.
  for Def_Enum_Table'Component_Size use Default_Component_Size;  -- N/A => ERROR.
  type Sparse_Mod_Table  is
  type Sparse_Mod_Table  is
       array(Test_Width) of Mod_Same_Size_As_Sparse_Enum;
       array(Test_Width) of Mod_Same_Size_As_Sparse_Enum;
  for Sparse_Mod_Table'Component_Size use Sparse_Component_Size;  -- N/A => ERROR.
  for Sparse_Mod_Table'Component_Size use Sparse_Component_Size;  -- N/A => ERROR.
  type Default_Mod_Table is
  type Default_Mod_Table is
       array(Test_Width) of Mod_Same_Size_As_Def_Enum;
       array(Test_Width) of Mod_Same_Size_As_Def_Enum;
  for Default_Mod_Table'Component_Size use Default_Component_Size;  -- N/A => ERROR.
  for Default_Mod_Table'Component_Size use Default_Component_Size;  -- N/A => ERROR.
  function UC_Sparse_Mod_Enum is
  function UC_Sparse_Mod_Enum is
    new Ada.Unchecked_Conversion( Sparse_Mod_Table, Sparse_Enum_Table );
    new Ada.Unchecked_Conversion( Sparse_Mod_Table, Sparse_Enum_Table );
  function UC_Def_Mod_Enum is
  function UC_Def_Mod_Enum is
    new Ada.Unchecked_Conversion( Default_Mod_Table, Def_Enum_Table );
    new Ada.Unchecked_Conversion( Default_Mod_Table, Def_Enum_Table );
  Valid_Sparse_Values : Sparse_Enum_Table;
  Valid_Sparse_Values : Sparse_Enum_Table;
  Valid_Def_Values    : Def_Enum_Table;
  Valid_Def_Values    : Def_Enum_Table;
  Sample_Enum_Value_Table : Sparse_Mod_Table;
  Sample_Enum_Value_Table : Sparse_Mod_Table;
  Sample_Def_Value_Table  : Default_Mod_Table;
  Sample_Def_Value_Table  : Default_Mod_Table;
  -- fill the Valid tables with valid values for conversion
  -- fill the Valid tables with valid values for conversion
  procedure Fill_Valid is
  procedure Fill_Valid is
    K : Mod_10 := 0;
    K : Mod_10 := 0;
    P : Mod_By_Enum_Items := 0;
    P : Mod_By_Enum_Items := 0;
  begin
  begin
    for I in Test_Width loop
    for I in Test_Width loop
      Valid_Sparse_Values(I) := Sparse_Enumerated'Val( K );
      Valid_Sparse_Values(I) := Sparse_Enumerated'Val( K );
      Valid_Def_Values(I)    := Default_Enumerated'Val( Integer(P) );
      Valid_Def_Values(I)    := Default_Enumerated'Val( Integer(P) );
      K := K +1;
      K := K +1;
      P := P +1;
      P := P +1;
    end loop;
    end loop;
  end Fill_Valid;
  end Fill_Valid;
  -- fill the Sample tables with invalid values for conversion
  -- fill the Sample tables with invalid values for conversion
  procedure Fill_Invalid is
  procedure Fill_Invalid is
    K : Mod_Same_Size_As_Sparse_Enum := 1;
    K : Mod_Same_Size_As_Sparse_Enum := 1;
    P : Mod_Same_Size_As_Def_Enum    := 1;
    P : Mod_Same_Size_As_Def_Enum    := 1;
  begin
  begin
    for I in Test_Width loop
    for I in Test_Width loop
      K := K +13;
      K := K +13;
      if K mod 2 = 0 then  -- oops, that would be a valid value
      if K mod 2 = 0 then  -- oops, that would be a valid value
        K := K +1;
        K := K +1;
      end if;
      end if;
      if P = Mod_Same_Size_As_Def_Enum'Last
      if P = Mod_Same_Size_As_Def_Enum'Last
         or P < Default_Enumerated_Count then -- that would be valid
         or P < Default_Enumerated_Count then -- that would be valid
        P := Default_Enumerated_Count + 1;
        P := Default_Enumerated_Count + 1;
      else
      else
        P := P +1;
        P := P +1;
      end if;
      end if;
      Sample_Enum_Value_Table(I) := K;
      Sample_Enum_Value_Table(I) := K;
      Sample_Def_Value_Table(I)  := P;
      Sample_Def_Value_Table(I)  := P;
    end loop;
    end loop;
    Valid_Sparse_Values := UC_Sparse_Mod_Enum(Sample_Enum_Value_Table);
    Valid_Sparse_Values := UC_Sparse_Mod_Enum(Sample_Enum_Value_Table);
    Valid_Def_Values    := UC_Def_Mod_Enum(Sample_Def_Value_Table);
    Valid_Def_Values    := UC_Def_Mod_Enum(Sample_Def_Value_Table);
  end Fill_Invalid;
  end Fill_Invalid;
  -- fill the tables with second set of valid values for conversion
  -- fill the tables with second set of valid values for conversion
  procedure Refill_Valid is
  procedure Refill_Valid is
    K : Mod_10 := 0;
    K : Mod_10 := 0;
    P : Mod_By_Enum_Items := 0;
    P : Mod_By_Enum_Items := 0;
    Table : Array(Mod_10) of Mod_Same_Size_As_Sparse_Enum
    Table : Array(Mod_10) of Mod_Same_Size_As_Sparse_Enum
          := ( 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 );
          := ( 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 );
  begin
  begin
    for I in Test_Width loop
    for I in Test_Width loop
      Sample_Enum_Value_Table(I) := Table(K);
      Sample_Enum_Value_Table(I) := Table(K);
      Sample_Def_Value_Table(I)  := Mod_Same_Size_As_Def_Enum(P);
      Sample_Def_Value_Table(I)  := Mod_Same_Size_As_Def_Enum(P);
      K := K +1;
      K := K +1;
      P := P +1;
      P := P +1;
    end loop;
    end loop;
    Valid_Sparse_Values := UC_Sparse_Mod_Enum(Sample_Enum_Value_Table);
    Valid_Sparse_Values := UC_Sparse_Mod_Enum(Sample_Enum_Value_Table);
    Valid_Def_Values    := UC_Def_Mod_Enum(Sample_Def_Value_Table);
    Valid_Def_Values    := UC_Def_Mod_Enum(Sample_Def_Value_Table);
  end Refill_Valid;
  end Refill_Valid;
  procedure Validate(Expect_Valid: Boolean) is
  procedure Validate(Expect_Valid: Boolean) is
  begin  -- here's where we actually use the tested attribute
  begin  -- here's where we actually use the tested attribute
    for K in Test_Width loop
    for K in Test_Width loop
      if Valid_Sparse_Values(K)'Valid /= Expect_Valid then
      if Valid_Sparse_Values(K)'Valid /= Expect_Valid then
        Report.Failed("Expected 'Valid =" & Boolean'Image(Expect_Valid)
        Report.Failed("Expected 'Valid =" & Boolean'Image(Expect_Valid)
                    & " for Sparse item " & Integer'Image(K) );
                    & " for Sparse item " & Integer'Image(K) );
      end if;
      end if;
    end loop;
    end loop;
    for P in Test_Width loop
    for P in Test_Width loop
      if Valid_Def_Values(P)'Valid /= Expect_Valid then
      if Valid_Def_Values(P)'Valid /= Expect_Valid then
        Report.Failed("Expected 'Valid =" & Boolean'Image(Expect_Valid)
        Report.Failed("Expected 'Valid =" & Boolean'Image(Expect_Valid)
                    & " for Default item " & Integer'Image(P) );
                    & " for Default item " & Integer'Image(P) );
      end if;
      end if;
    end loop;
    end loop;
  end Validate;
  end Validate;
begin  -- Main test procedure.
begin  -- Main test procedure.
  Report.Test ("CD92001", "Check object attribute: X'Valid" );
  Report.Test ("CD92001", "Check object attribute: X'Valid" );
  Fill_Valid;
  Fill_Valid;
  Validate(True);
  Validate(True);
  Fill_Invalid;
  Fill_Invalid;
  Validate(False);
  Validate(False);
  Refill_Valid;
  Refill_Valid;
  Validate(True);
  Validate(True);
  Report.Result;
  Report.Result;
end CD92001;
end CD92001;
 
 

powered by: WebSVN 2.1.0

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