| 1 |
-- CD30012.A |
| 2 |
|
| 3 |
-- Grant of Unlimited Rights |
| 4 |
-- |
| 5 |
-- The Ada Conformity Assessment Authority (ACAA) holds unlimited |
| 6 |
-- rights in the software and documentation contained herein. Unlimited |
| 7 |
-- rights are the same as those granted by the U.S. Government for older |
| 8 |
-- parts of the Ada Conformity Assessment Test Suite, and are defined |
| 9 |
-- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA |
| 10 |
-- intends to confer upon all recipients unlimited rights equal to those |
| 11 |
-- held by the ACAA. These rights include rights to use, duplicate, |
| 12 |
-- release or disclose the released technical data and computer software |
| 13 |
-- in whole or in part, in any manner and for any purpose whatsoever, and |
| 14 |
-- to have or permit others to do so. |
| 15 |
-- |
| 16 |
-- DISCLAIMER |
| 17 |
-- |
| 18 |
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR |
| 19 |
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED |
| 20 |
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE |
| 21 |
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE |
| 22 |
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A |
| 23 |
-- PARTICULAR PURPOSE OF SAID MATERIAL. |
| 24 |
-- |
| 25 |
-- Notice |
| 26 |
-- |
| 27 |
-- The ACAA has created and maintains the Ada Conformity Assessment Test |
| 28 |
-- Suite for the purpose of conformity assessments conducted in accordance |
| 29 |
-- with the International Standard ISO/IEC 18009 - Ada: Conformity |
| 30 |
-- assessment of a language processor. This test suite should not be used |
| 31 |
-- to make claims of conformance unless used in accordance with |
| 32 |
-- ISO/IEC 18009 and any applicable ACAA procedures. |
| 33 |
-- |
| 34 |
--* |
| 35 |
-- OBJECTIVE: |
| 36 |
-- Check that a size specification can be given by an attribute definition |
| 37 |
-- clause for an integer type: |
| 38 |
-- * in the visible or private part of a package for a type declared |
| 39 |
-- in the visible part; |
| 40 |
-- * for a derived integer type; |
| 41 |
-- * for a derived private type whose full declaration is an |
| 42 |
-- integer type. |
| 43 |
-- |
| 44 |
-- TEST DESCRIPTION: |
| 45 |
-- This test was created from legacy tests CD1009B and CD2A31C. The |
| 46 |
-- objective of CD1009B was also an objective of CD30012; the tests |
| 47 |
-- were merged to eliminate duplication and add appropriate applicability |
| 48 |
-- criteria. |
| 49 |
-- |
| 50 |
-- APPLICABILITY CRITERIA: |
| 51 |
-- All implementations must attempt to compile this test. |
| 52 |
-- |
| 53 |
-- For implementations validating against Systems Programming Annex (C): |
| 54 |
-- this test must execute and report PASSED. |
| 55 |
-- |
| 56 |
-- or implementations not validating against Annex C: |
| 57 |
-- this test may report compile time errors at one or more points |
| 58 |
-- indicated by "-- ANX-C RQMT", in which case it may be graded as |
| 59 |
-- inapplicable. Otherwise, the test must execute and report PASSED. |
| 60 |
-- |
| 61 |
-- CHANGE HISTORY: |
| 62 |
-- 17 Jun 87 PWB Created original test CD2A31C. |
| 63 |
-- 09 Sep 87 VCL Created original test CD1009A. |
| 64 |
-- 06 Apr 89 DHH Changed extension from '.DEP' TO '.ADA', changed |
| 65 |
-- size clause value to 9, and added representation |
| 66 |
-- clause check and included test for for integer in a |
| 67 |
-- generic unit. |
| 68 |
-- 27 Mar 92 JRL Removed testing of nonobjective types. |
| 69 |
-- 17 Jun 92 DTN Removed the length clause for type Private_Int. |
| 70 |
-- 29 Mar 17 RLB Created test from CD2A31C and CD1009A; reformatted |
| 71 |
-- to "modern" standards, added applicability criteria, |
| 72 |
-- removed nonobjective packed array. |
| 73 |
|
| 74 |
with Report; use Report; |
| 75 |
with Length_Check; -- Contains a call to 'Failed'. |
| 76 |
procedure CD30012 is |
| 77 |
|
| 78 |
type Basic_Int is range -60 .. 80; |
| 79 |
Specified_Size : constant := 9; |
| 80 |
|
| 81 |
type Derived_Int is new Basic_Int; |
| 82 |
for Derived_Int'Size use Specified_Size; -- ANX-C RQMT. |
| 83 |
|
| 84 |
package P is |
| 85 |
type Int_in_P is range -125 .. 125; |
| 86 |
for Int_in_P'Size use Specified_Size; -- ANX-C RQMT. |
| 87 |
type Private_Int is private; |
| 88 |
type Alt_Int_in_P is range -125 .. 125; |
| 89 |
private |
| 90 |
type Private_Int is range -125 .. 125; |
| 91 |
for Alt_Int_in_P'Size use Specified_Size; -- ANX-C RQMT. |
| 92 |
end P; |
| 93 |
|
| 94 |
use P; |
| 95 |
type Derived_Private_Int is new Private_Int; |
| 96 |
for Derived_Private_Int'Size use Specified_Size; -- ANX-C RQMT. |
| 97 |
Minimum_Size : Integer := Report.Ident_Int (Specified_Size); |
| 98 |
|
| 99 |
-- Size specification given in a generic procedure: |
| 100 |
|
| 101 |
generic |
| 102 |
procedure Genproc; |
| 103 |
|
| 104 |
procedure Genproc is |
| 105 |
type Check_Int is range -125 .. 125; |
| 106 |
for Check_Int'Size use Specified_Size; -- ANX-C RQMT. |
| 107 |
|
| 108 |
procedure Check_4 is new Length_Check (Check_Int); |
| 109 |
|
| 110 |
begin |
| 111 |
|
| 112 |
if Check_Int'Size /= Minimum_Size then |
| 113 |
Failed ("Generic Check_Int'Size is incorrect"); |
| 114 |
end if; |
| 115 |
Check_4 (-60, 9, "generic Check_Int"); |
| 116 |
|
| 117 |
end Genproc; |
| 118 |
|
| 119 |
procedure Newproc is new Genproc; |
| 120 |
|
| 121 |
procedure Check_1 is new Length_Check (Derived_Int); |
| 122 |
procedure Check_2 is new Length_Check (Int_in_P); |
| 123 |
procedure Check_3 is new Length_Check (Alt_Int_in_P); |
| 124 |
|
| 125 |
Obj1 : Int_in_P := 92; |
| 126 |
Obj2 : Alt_Int_in_P := 52; |
| 127 |
|
| 128 |
begin |
| 129 |
|
| 130 |
Report.Test ("CD30012", "Check that 'Size attribute definition clauses " & |
| 131 |
"can be given in the visible or private part " & |
| 132 |
"of a package for integer types declared " & |
| 133 |
"declared in the visible part, and for derived " & |
| 134 |
"integer types and derived private types " & |
| 135 |
"whose full declarations are as integer types"); |
| 136 |
|
| 137 |
Check_1 (-60, 9, "Derived_Int"); |
| 138 |
Check_2 (-60, 9, "Int_in_P"); |
| 139 |
Check_3 (-60, 9, "Alt_Int_in_P"); |
| 140 |
Check_2 (Obj1, 9, "Int_in_P"); |
| 141 |
Check_3 (Obj2, 9, "Alt_Int_in_P"); |
| 142 |
|
| 143 |
Newproc; |
| 144 |
|
| 145 |
if Derived_Int'Size /= Minimum_Size then |
| 146 |
Failed ("Derived_Int'Size incorrect"); |
| 147 |
end if; |
| 148 |
|
| 149 |
if Int_in_P'Size /= Minimum_Size then |
| 150 |
Failed ("Int_in_P'Size incorrect"); |
| 151 |
end if; |
| 152 |
|
| 153 |
if Alt_Int_in_P'Size /= Minimum_Size then |
| 154 |
Failed ("Alt_Int_in_P'Size incorrect"); |
| 155 |
end if; |
| 156 |
|
| 157 |
if Derived_Private_Int'Size /= Minimum_Size then |
| 158 |
Failed ("Derived_Private_Int'Size incorrect"); |
| 159 |
end if; |
| 160 |
|
| 161 |
if Obj1'Size < Specified_Size then |
| 162 |
Failed ("Object'Size is too small --" & |
| 163 |
Int_in_P'Image (Obj1)); |
| 164 |
end if; |
| 165 |
|
| 166 |
if Obj2'Size < Specified_Size then |
| 167 |
Failed ("Object'Size is too small --" & |
| 168 |
Alt_Int_in_P'Image (Obj2)); |
| 169 |
end if; |
| 170 |
|
| 171 |
Report.Result; |
| 172 |
|
| 173 |
end CD30012; |