-- C641001.A
|
-- C641001.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 actual parameters passed by reference are view converted
|
-- Check that actual parameters passed by reference are view converted
|
-- to the nominal subtype of the formal parameter.
|
-- to the nominal subtype of the formal parameter.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- Check that sliding is allowed for formal parameters, especially
|
-- Check that sliding is allowed for formal parameters, especially
|
-- check cases that would have caused errors in Ada'83.
|
-- check cases that would have caused errors in Ada'83.
|
-- Check that length check for a formal parameter (esp out mode)
|
-- Check that length check for a formal parameter (esp out mode)
|
-- is performed before the call, not after.
|
-- is performed before the call, not after.
|
--
|
--
|
-- notes: 6.2; by reference ::= tagged, task, protected,
|
-- notes: 6.2; by reference ::= tagged, task, protected,
|
-- limited (nonprivate), or composite containing such
|
-- limited (nonprivate), or composite containing such
|
-- 4.6; view conversion
|
-- 4.6; view conversion
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 26 JAN 96 SAIC Initial version
|
-- 26 JAN 96 SAIC Initial version
|
-- 04 NOV 96 SAIC Commentary revision for release 2.1
|
-- 04 NOV 96 SAIC Commentary revision for release 2.1
|
-- 27 FEB 97 PWB.CTA Corrected reference to the wrong string
|
-- 27 FEB 97 PWB.CTA Corrected reference to the wrong string
|
--!
|
--!
|
|
|
----------------------------------------------------------------- C641001_0
|
----------------------------------------------------------------- C641001_0
|
|
|
package C641001_0 is
|
package C641001_0 is
|
|
|
subtype String_10 is String(1..10);
|
subtype String_10 is String(1..10);
|
|
|
procedure Check_String_10( S : out String_10; Start, Stop: Natural );
|
procedure Check_String_10( S : out String_10; Start, Stop: Natural );
|
|
|
procedure Check_Illegal_Slice_Reference( Slice_Passed : in out String;
|
procedure Check_Illegal_Slice_Reference( Slice_Passed : in out String;
|
Index: Natural );
|
Index: Natural );
|
|
|
type Tagged_Data(Bound: Natural) is tagged record
|
type Tagged_Data(Bound: Natural) is tagged record
|
Data_Item : String(1..Bound) := (others => '*');
|
Data_Item : String(1..Bound) := (others => '*');
|
end record;
|
end record;
|
|
|
type Tag_List is array(Natural range <>) of Tagged_Data(5);
|
type Tag_List is array(Natural range <>) of Tagged_Data(5);
|
|
|
subtype Tag_List_10 is Tag_List(1..10);
|
subtype Tag_List_10 is Tag_List(1..10);
|
|
|
procedure Check_Tag_Slice( TL : in out Tag_List_10 );
|
procedure Check_Tag_Slice( TL : in out Tag_List_10 );
|
|
|
procedure Check_Out_Tagged_Data( Formal : out Tagged_Data );
|
procedure Check_Out_Tagged_Data( Formal : out Tagged_Data );
|
|
|
end C641001_0;
|
end C641001_0;
|
|
|
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
|
|
with Report;
|
with Report;
|
with TCTouch;
|
with TCTouch;
|
package body C641001_0 is
|
package body C641001_0 is
|
|
|
String_Data : constant String := "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
String_Data : constant String := "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
procedure Check_String_10( S : out String_10; Start, Stop: Natural ) is
|
procedure Check_String_10( S : out String_10; Start, Stop: Natural ) is
|
begin
|
begin
|
if S'Length /= 10 then
|
if S'Length /= 10 then
|
Report.Failed("Length check not performed prior to execution");
|
Report.Failed("Length check not performed prior to execution");
|
end if;
|
end if;
|
S := String_Data(Start..Stop);
|
S := String_Data(Start..Stop);
|
exception
|
exception
|
when others => Report.Failed("Exception encountered in Check_String_10");
|
when others => Report.Failed("Exception encountered in Check_String_10");
|
end Check_String_10;
|
end Check_String_10;
|
|
|
procedure Check_Illegal_Slice_Reference( Slice_Passed : in out String;
|
procedure Check_Illegal_Slice_Reference( Slice_Passed : in out String;
|
Index: Natural ) is
|
Index: Natural ) is
|
begin
|
begin
|
-- essentially "do-nothing" for optimization foilage...
|
-- essentially "do-nothing" for optimization foilage...
|
if Slice_Passed(Index) in Character then
|
if Slice_Passed(Index) in Character then
|
-- Intent is ^^^^^ should raise Constraint_Error
|
-- Intent is ^^^^^ should raise Constraint_Error
|
Report.Failed("Illegal Slice provided legal character");
|
Report.Failed("Illegal Slice provided legal character");
|
else
|
else
|
Report.Failed("Illegal Slice provided illegal character");
|
Report.Failed("Illegal Slice provided illegal character");
|
end if;
|
end if;
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
null; -- expected case
|
null; -- expected case
|
when others =>
|
when others =>
|
Report.Failed("Wrong exception in Check_Illegal_Slice_Reference");
|
Report.Failed("Wrong exception in Check_Illegal_Slice_Reference");
|
end Check_Illegal_Slice_Reference;
|
end Check_Illegal_Slice_Reference;
|
|
|
procedure Check_Tag_Slice( TL : in out Tag_List_10 ) is
|
procedure Check_Tag_Slice( TL : in out Tag_List_10 ) is
|
-- if the view conversion is not performed, one of the following checks
|
-- if the view conversion is not performed, one of the following checks
|
-- will fail (given data passed as 0..9 and then 2..11)
|
-- will fail (given data passed as 0..9 and then 2..11)
|
begin
|
begin
|
Check_Under_Index: -- index 0 should raise C_E
|
Check_Under_Index: -- index 0 should raise C_E
|
begin
|
begin
|
TCTouch.Assert( TL(Report.Ident_Int(0)).Data_Item = "*****",
|
TCTouch.Assert( TL(Report.Ident_Int(0)).Data_Item = "*****",
|
"Index 0 (illegal); bad data" );
|
"Index 0 (illegal); bad data" );
|
Report.Failed("Index 0 did not raise Constraint_Error");
|
Report.Failed("Index 0 did not raise Constraint_Error");
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
null; -- expected case
|
null; -- expected case
|
when others =>
|
when others =>
|
Report.Failed("Wrong exception in Check_Under_Index ");
|
Report.Failed("Wrong exception in Check_Under_Index ");
|
end Check_Under_Index;
|
end Check_Under_Index;
|
|
|
Check_Over_Index: -- index 11 should raise C_E
|
Check_Over_Index: -- index 11 should raise C_E
|
begin
|
begin
|
TCTouch.Assert( TL(Report.Ident_Int(11)).Data_Item = "*****",
|
TCTouch.Assert( TL(Report.Ident_Int(11)).Data_Item = "*****",
|
"Index 11 (illegal); bad data" );
|
"Index 11 (illegal); bad data" );
|
Report.Failed("Index 11 did not raise Constraint_Error");
|
Report.Failed("Index 11 did not raise Constraint_Error");
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
null; -- expected case
|
null; -- expected case
|
when others =>
|
when others =>
|
Report.Failed("Wrong exception in Check_Over_Index ");
|
Report.Failed("Wrong exception in Check_Over_Index ");
|
end Check_Over_Index;
|
end Check_Over_Index;
|
|
|
end Check_Tag_Slice;
|
end Check_Tag_Slice;
|
|
|
procedure Check_Out_Tagged_Data( Formal : out Tagged_Data ) is
|
procedure Check_Out_Tagged_Data( Formal : out Tagged_Data ) is
|
begin
|
begin
|
TCTouch.Assert( Formal.Data_Item = "*****", "out formal data bad" );
|
TCTouch.Assert( Formal.Data_Item = "*****", "out formal data bad" );
|
Formal.Data_Item(1) := '!';
|
Formal.Data_Item(1) := '!';
|
end Check_Out_Tagged_Data;
|
end Check_Out_Tagged_Data;
|
|
|
end C641001_0;
|
end C641001_0;
|
|
|
------------------------------------------------------------------- C641001
|
------------------------------------------------------------------- C641001
|
|
|
with Report;
|
with Report;
|
with TCTouch;
|
with TCTouch;
|
with C641001_0;
|
with C641001_0;
|
procedure C641001 is
|
procedure C641001 is
|
|
|
function II( I: Integer ) return Integer renames Report.Ident_Int;
|
function II( I: Integer ) return Integer renames Report.Ident_Int;
|
-- ^^ name chosen to allow embedding in calls
|
-- ^^ name chosen to allow embedding in calls
|
|
|
A_String_10 : C641001_0.String_10;
|
A_String_10 : C641001_0.String_10;
|
Slicable : String(1..40);
|
Slicable : String(1..40);
|
Tag_Slices : C641001_0.Tag_List(0..11);
|
Tag_Slices : C641001_0.Tag_List(0..11);
|
|
|
Global_Data : String(1..26) := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
Global_Data : String(1..26) := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
procedure Check_Out_Sliding( Lo1, Hi1, Lo2, Hi2 : Natural ) is
|
procedure Check_Out_Sliding( Lo1, Hi1, Lo2, Hi2 : Natural ) is
|
|
|
subtype One_Constrained_String is String(Lo1..Hi1); -- 1 5
|
subtype One_Constrained_String is String(Lo1..Hi1); -- 1 5
|
subtype Two_Constrained_String is String(Lo2..Hi2); -- 6 10
|
subtype Two_Constrained_String is String(Lo2..Hi2); -- 6 10
|
|
|
procedure Out_Param( Param : out One_Constrained_String ) is
|
procedure Out_Param( Param : out One_Constrained_String ) is
|
begin
|
begin
|
Param := Report.Ident_Str( Global_Data(Lo2..Hi2) );
|
Param := Report.Ident_Str( Global_Data(Lo2..Hi2) );
|
end Out_Param;
|
end Out_Param;
|
Object : Two_Constrained_String;
|
Object : Two_Constrained_String;
|
begin
|
begin
|
Out_Param( Object );
|
Out_Param( Object );
|
if Object /= Report.Ident_Str( Global_Data(Lo2..Hi2) ) then
|
if Object /= Report.Ident_Str( Global_Data(Lo2..Hi2) ) then
|
Report.Failed("Bad result in Check_Out_Sliding");
|
Report.Failed("Bad result in Check_Out_Sliding");
|
end if;
|
end if;
|
exception
|
exception
|
when others => Report.Failed("Exception in Check_Out_Sliding");
|
when others => Report.Failed("Exception in Check_Out_Sliding");
|
end Check_Out_Sliding;
|
end Check_Out_Sliding;
|
|
|
procedure Check_Dynamic_Subtype_Cases(F_Lower,F_Upper: Natural;
|
procedure Check_Dynamic_Subtype_Cases(F_Lower,F_Upper: Natural;
|
A_Lower,A_Upper: Natural) is
|
A_Lower,A_Upper: Natural) is
|
|
|
subtype Dyn_String is String(F_Lower..F_Upper);
|
subtype Dyn_String is String(F_Lower..F_Upper);
|
|
|
procedure Check_Dyn_Subtype_Formal_Out( Param : out Dyn_String ) is
|
procedure Check_Dyn_Subtype_Formal_Out( Param : out Dyn_String ) is
|
begin
|
begin
|
Param := Global_Data(11..20);
|
Param := Global_Data(11..20);
|
end Check_Dyn_Subtype_Formal_Out;
|
end Check_Dyn_Subtype_Formal_Out;
|
|
|
procedure Check_Dyn_Subtype_Formal_In( Param : in Dyn_String ) is
|
procedure Check_Dyn_Subtype_Formal_In( Param : in Dyn_String ) is
|
begin
|
begin
|
if Param /= Global_Data(11..20) then
|
if Param /= Global_Data(11..20) then
|
Report.Failed("Dynamic case, data mismatch");
|
Report.Failed("Dynamic case, data mismatch");
|
end if;
|
end if;
|
end Check_Dyn_Subtype_Formal_In;
|
end Check_Dyn_Subtype_Formal_In;
|
|
|
Stuff: String(A_Lower..A_Upper);
|
Stuff: String(A_Lower..A_Upper);
|
|
|
begin
|
begin
|
Check_Dyn_Subtype_Formal_Out( Stuff );
|
Check_Dyn_Subtype_Formal_Out( Stuff );
|
Check_Dyn_Subtype_Formal_In( Stuff );
|
Check_Dyn_Subtype_Formal_In( Stuff );
|
end Check_Dynamic_Subtype_Cases;
|
end Check_Dynamic_Subtype_Cases;
|
|
|
begin -- Main test procedure.
|
begin -- Main test procedure.
|
|
|
Report.Test ("C641001", "Check that actual parameters passed by " &
|
Report.Test ("C641001", "Check that actual parameters passed by " &
|
"reference are view converted to the nominal " &
|
"reference are view converted to the nominal " &
|
"subtype of the formal parameter" );
|
"subtype of the formal parameter" );
|
|
|
-- non error cases for string slices
|
-- non error cases for string slices
|
|
|
C641001_0.Check_String_10( A_String_10, 1, 10 );
|
C641001_0.Check_String_10( A_String_10, 1, 10 );
|
TCTouch.Assert( A_String_10 = "1234567890", "Nominal case" );
|
TCTouch.Assert( A_String_10 = "1234567890", "Nominal case" );
|
|
|
C641001_0.Check_String_10( A_String_10, 11, 20 );
|
C641001_0.Check_String_10( A_String_10, 11, 20 );
|
TCTouch.Assert( A_String_10 = "ABCDEFGHIJ", "Sliding to subtype" );
|
TCTouch.Assert( A_String_10 = "ABCDEFGHIJ", "Sliding to subtype" );
|
|
|
C641001_0.Check_String_10( Slicable(1..10), 1, 10 );
|
C641001_0.Check_String_10( Slicable(1..10), 1, 10 );
|
TCTouch.Assert( Slicable(1..10) = "1234567890", "Slice, no sliding" );
|
TCTouch.Assert( Slicable(1..10) = "1234567890", "Slice, no sliding" );
|
|
|
C641001_0.Check_String_10( Slicable(1..10), 21, 30 );
|
C641001_0.Check_String_10( Slicable(1..10), 21, 30 );
|
TCTouch.Assert( Slicable(1..10) = "KLMNOPQRST", "Sliding to slice" );
|
TCTouch.Assert( Slicable(1..10) = "KLMNOPQRST", "Sliding to slice" );
|
|
|
C641001_0.Check_String_10( Slicable(11..20), 11, 20 );
|
C641001_0.Check_String_10( Slicable(11..20), 11, 20 );
|
TCTouch.Assert( Slicable(11..20) = "ABCDEFGHIJ", "Sliding to same" );
|
TCTouch.Assert( Slicable(11..20) = "ABCDEFGHIJ", "Sliding to same" );
|
|
|
C641001_0.Check_String_10( Slicable(21..30), 11, 20 );
|
C641001_0.Check_String_10( Slicable(21..30), 11, 20 );
|
TCTouch.Assert( Slicable(21..30) = "ABCDEFGHIJ", "Sliding up" );
|
TCTouch.Assert( Slicable(21..30) = "ABCDEFGHIJ", "Sliding up" );
|
|
|
-- error cases for string slices
|
-- error cases for string slices
|
|
|
C641001_0.Check_Illegal_Slice_Reference( Slicable(21..30), 20 );
|
C641001_0.Check_Illegal_Slice_Reference( Slicable(21..30), 20 );
|
|
|
C641001_0.Check_Illegal_Slice_Reference( Slicable(1..15), Slicable'Last );
|
C641001_0.Check_Illegal_Slice_Reference( Slicable(1..15), Slicable'Last );
|
|
|
-- checks for view converting actuals to formals
|
-- checks for view converting actuals to formals
|
|
|
-- catch low bound fault
|
-- catch low bound fault
|
C641001_0.Check_Tag_Slice( Tag_Slices(II(0)..9) ); -- II ::= Ident_Int
|
C641001_0.Check_Tag_Slice( Tag_Slices(II(0)..9) ); -- II ::= Ident_Int
|
TCTouch.Assert( Tag_Slices'First = 0, "Tag_Slices'First = 0" );
|
TCTouch.Assert( Tag_Slices'First = 0, "Tag_Slices'First = 0" );
|
TCTouch.Assert( Tag_Slices'Last = 11, "Tag_Slices'Last = 11" );
|
TCTouch.Assert( Tag_Slices'Last = 11, "Tag_Slices'Last = 11" );
|
|
|
-- catch high bound fault
|
-- catch high bound fault
|
C641001_0.Check_Tag_Slice( Tag_Slices(2..II(11)) );
|
C641001_0.Check_Tag_Slice( Tag_Slices(2..II(11)) );
|
TCTouch.Assert( Tag_Slices'First = 0, "Tag_Slices'First = 0" );
|
TCTouch.Assert( Tag_Slices'First = 0, "Tag_Slices'First = 0" );
|
TCTouch.Assert( Tag_Slices'Last = 11, "Tag_Slices'Last = 11" );
|
TCTouch.Assert( Tag_Slices'Last = 11, "Tag_Slices'Last = 11" );
|
|
|
Check_Formal_Association_Check:
|
Check_Formal_Association_Check:
|
begin
|
begin
|
C641001_0.Check_String_10( Slicable, 1, 10 ); -- catch length fault
|
C641001_0.Check_String_10( Slicable, 1, 10 ); -- catch length fault
|
Report.Failed("Exception not raised at Check_Formal_Association_Check");
|
Report.Failed("Exception not raised at Check_Formal_Association_Check");
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
null; -- expected case
|
null; -- expected case
|
when others =>
|
when others =>
|
Report.Failed("Wrong exception at Check_Formal_Association_Check");
|
Report.Failed("Wrong exception at Check_Formal_Association_Check");
|
end Check_Formal_Association_Check;
|
end Check_Formal_Association_Check;
|
|
|
-- check for constrained actual, unconstrained formal
|
-- check for constrained actual, unconstrained formal
|
C641001_0.Check_Out_Tagged_Data( Tag_Slices(5) );
|
C641001_0.Check_Out_Tagged_Data( Tag_Slices(5) );
|
TCTouch.Assert( Tag_Slices(5).Data_Item = "!****",
|
TCTouch.Assert( Tag_Slices(5).Data_Item = "!****",
|
"formal out returned bad result" );
|
"formal out returned bad result" );
|
|
|
-- additional checks for out mode formal parameters, dynamic subtypes
|
-- additional checks for out mode formal parameters, dynamic subtypes
|
|
|
Check_Out_Sliding( II(1),II(5), II(6),II(10) );
|
Check_Out_Sliding( II(1),II(5), II(6),II(10) );
|
|
|
Check_Out_Sliding( 21,25, 6,10 );
|
Check_Out_Sliding( 21,25, 6,10 );
|
|
|
Check_Dynamic_Subtype_Cases(F_Lower => II(1), F_Upper => II(10),
|
Check_Dynamic_Subtype_Cases(F_Lower => II(1), F_Upper => II(10),
|
A_Lower => II(1), A_Upper => II(10));
|
A_Lower => II(1), A_Upper => II(10));
|
|
|
Check_Dynamic_Subtype_Cases(F_Lower => II(21), F_Upper => II(30),
|
Check_Dynamic_Subtype_Cases(F_Lower => II(21), F_Upper => II(30),
|
A_Lower => II( 1), A_Upper => II(10));
|
A_Lower => II( 1), A_Upper => II(10));
|
|
|
Check_Dynamic_Subtype_Cases(F_Lower => II( 1), F_Upper => II(10),
|
Check_Dynamic_Subtype_Cases(F_Lower => II( 1), F_Upper => II(10),
|
A_Lower => II(21), A_Upper => II(30));
|
A_Lower => II(21), A_Upper => II(30));
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end C641001;
|
end C641001;
|
|
|