1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
-- C460005.A
--
-- Grant of Unlimited Rights
--
-- 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
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- 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
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
--
-- OBJECTIVE:
-- Check that, for a view conversion of a tagged type that is the left
-- side of an assignment statement, the assignment assigns to the
-- corresponding part of the object denoted by the operand.
--
-- TEST DESCRIPTION:
-- View conversions of class-wide operands to specific types are
-- placed on the right and left sides of assignment statements, and
-- conversions of class-wide operands to class-wide types are used
-- as actual parameters to dispatching operations. In all cases, a
-- check is made that Constraint_Error is raised if the tag of the
-- operand does not identify a specific type covered by or descended
-- from the target type, and not raised otherwise.
--
-- For the cases where the view conversion is the left side of an
-- assignment statement, and Constraint_Error should not be raised,
-- an additional check is made that only the corresponding portion
-- of the operand is updated by the assignment. For example:
--
-- type T is tagged record
-- C1 : Integer := 0;
-- end record;
--
-- type DT is new T with record
-- C2 : Integer := 0;
-- end record;
--
-- A : T := (C1 => 5);
-- B : DT := (C1 => 0, C2 => 10);
-- CWDT : T'Class := B;
--
-- T(CWDT) := A; -- Updates component C1; C2 remains unchanged.
-- -- Value of CWDT is (C1 => 5, C2 => 10).
--
--
-- CHANGE HISTORY:
-- 31 Jul 95 SAIC Initial prerelease version.
-- 22 Apr 96 SAIC ACVC 2.1: Added a check for correct tag.
-- 08 Sep 96 SAIC ACVC 2.1: Modified Report.Test.
--
--!
package C460005_0 is
type Tag_Type is tagged record
C1 : Natural;
end record;
procedure Proc (X : in out Tag_Type);
type DTag_Type is new Tag_Type with record
C2 : String (1 .. 5);
end record;
procedure Proc (X : in out DTag_Type);
type DDTag_Type is new DTag_Type with record
C3 : String (1 .. 5);
end record;
procedure Proc (X : in out DDTag_Type);
end C460005_0;
--==================================================================--
package body C460005_0 is
procedure Proc (X : in out Tag_Type) is
begin
X.C1 := 25;
end Proc;
-----------------------------------------
procedure Proc (X : in out DTag_Type) is
begin
Proc ( Tag_Type(X) );
X.C2 := "Earth";
end Proc;
-----------------------------------------
procedure Proc (X : in out DDTag_Type) is
begin
Proc ( DTag_Type(X) );
X.C3 := "Orbit";
end Proc;
end C460005_0;
--==================================================================--
with C460005_0;
use C460005_0;
with Report;
procedure C460005 is
Tag_Type_Init : constant Tag_Type := (C1 => 0);
DTag_Type_Init : constant DTag_Type := (Tag_Type_Init with "Hello");
DDTag_Type_Init : constant DDTag_Type := (DTag_Type_Init with "World");
Tag_Type_Value : constant Tag_Type := (C1 => 25);
DTag_Type_Value : constant DTag_Type := (Tag_Type_Value with "Earth");
DDTag_Type_Value : constant DDTag_Type := (DTag_Type_Value with "Orbit");
Tag_Type_Res : constant Tag_Type := (C1 => 25);
DTag_Type_Res : constant DTag_Type := (Tag_Type_Res with "Hello");
DDTag_Type_Res : constant DDTag_Type := (DTag_Type_Res with "World");
begin
Report.Test ("C460005", "Check that, for a view conversion of a tagged " &
"type that is the left side of an assignment statement, " &
"the assignment assigns to the corresponding part of the " &
"object denoted by the operand");
declare
procedure CW_Proc (P : Tag_Type'Class) is
Operand : Tag_Type'Class := P;
begin
Tag_Type(Operand) := Tag_Type_Value;
if (Operand /= Tag_Type'Class (Tag_Type_Value)) then
Report.Failed ("Operand has wrong value: #01");
end if;
exception
when Constraint_Error =>
Report.Failed ("Constraint_Error raised: #01");
when others =>
Report.Failed ("Unexpected exception: #01");
end CW_Proc;
begin
CW_Proc (Tag_Type_Init);
end;
----------------------------------------------------------------------
declare
procedure CW_Proc (P : Tag_Type'Class) is
Operand : Tag_Type'Class := P;
begin
DTag_Type(Operand) := DTag_Type_Value;
Report.Failed ("Constraint_Error not raised: #02");
exception
when Constraint_Error => null; -- expected exception
when others => Report.Failed ("Unexpected exception: #02");
end CW_Proc;
begin
CW_Proc (Tag_Type_Init);
end;
----------------------------------------------------------------------
declare
procedure CW_Proc (P : Tag_Type'Class) is
Operand : Tag_Type'Class := P;
begin
DDTag_Type(Operand) := DDTag_Type_Value;
Report.Failed ("Constraint_Error not raised: #03");
exception
when Constraint_Error => null; -- expected exception
when others => Report.Failed ("Unexpected exception: #03");
end CW_Proc;
begin
CW_Proc (Tag_Type_Init);
end;
----------------------------------------------------------------------
declare
procedure CW_Proc (P : Tag_Type'Class) is
Operand : Tag_Type'Class := P;
begin
Tag_Type(Operand) := Tag_Type_Value;
if Operand not in DTag_Type then
Report.Failed ("Operand has wrong tag: #04");
elsif (Operand /= Tag_Type'Class (DTag_Type_Res))
then -- Check to make
Report.Failed ("Operand has wrong value: #04"); -- sure that C2 was
end if; -- not modified.
exception
when Constraint_Error =>
Report.Failed ("Constraint_Error raised: #04");
when others =>
Report.Failed ("Unexpected exception: #04");
end CW_Proc;
begin
CW_Proc (DTag_Type_Init);
end;
----------------------------------------------------------------------
declare
procedure CW_Proc (P : Tag_Type'Class) is
Operand : Tag_Type'Class := P;
begin
Tag_Type(Operand) := Tag_Type_Value;
if Operand not in DDTag_Type then
Report.Failed ("Operand has wrong tag: #05");
elsif (Operand /= Tag_Type'Class (DDTag_Type_Res))
then -- Check to make
Report.Failed ("Operand has wrong value: #05"); -- sure that C2, C3
end if; -- were not changed.
exception
when Constraint_Error =>
Report.Failed ("Constraint_Error raised: #05");
when others =>
Report.Failed ("Unexpected exception: #05");
end CW_Proc;
begin
CW_Proc (DDTag_Type_Init);
end;
Report.Result;
end C460005;
|