3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
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.
27 -- Check that an exception declared in a package can be raised by a
28 -- client of a child of the package. Check that it can be renamed in
29 -- the client of the child of the package and raised with the correct
33 -- Declare a package which defines complex number abstraction with
34 -- user-defined exceptions (foundation code).
36 -- Add a public child package to the above package. Declare two
37 -- subprograms for the parent type.
39 -- In the main program, "with" the child package, then check that
40 -- an exception can be raised and handled as expected.
43 -- This test depends on the following foundation code:
49 -- 06 Dec 94 SAIC ACVC 2.0
53 -- Child package of FA11D00.
54 package FA11D00
.CA11D03_0
is -- Basic_Complex
56 function "+" (Left
, Right
: Complex_Type
)
57 return Complex_Type
; -- Add two complex numbers.
59 function "*" (Left
, Right
: Complex_Type
)
60 return Complex_Type
; -- Multiply two complex numbers.
62 end FA11D00
.CA11D03_0
; -- Basic_Complex
64 --=======================================================================--
66 package body FA11D00
.CA11D03_0
is -- Basic_Complex
68 function "+" (Left
, Right
: Complex_Type
) return Complex_Type
is
70 return ( (Left
.Real
+ Right
.Real
, Left
.Imag
+ Right
.Imag
) );
72 --------------------------------------------------------------
73 function "*" (Left
, Right
: Complex_Type
) return Complex_Type
is
75 return ( Real
=> (Left
.Real
* Right
.Real
),
76 Imag
=> (Left
.Imag
* Right
.Imag
) );
79 end FA11D00
.CA11D03_0
; -- Basic_Complex
81 --=======================================================================--
83 with FA11D00
.CA11D03_0
; -- Basic_Complex,
84 -- implicitly with Complex_Definition.
89 package Complex_Pkg
renames FA11D00
; -- Complex_Definition_Pkg
90 package Basic_Complex_Pkg
renames FA11D00
.CA11D03_0
; -- Basic_Complex
93 use Basic_Complex_Pkg
;
95 TC_Handled_In_Subtest_1
,
96 TC_Handled_In_Subtest_2
: boolean := false;
100 Report
.Test
("CA11D03", "Check that an exception declared in a package " &
101 "can be raised by a client of a child of the package");
103 Multiply_Complex_Subtest
:
105 Operand_1
: Complex_Type
:= Complex
(Int_Type
(Report
.Ident_Int
(3)),
106 Int_Type
(Report
.Ident_Int
(2)));
107 -- Referenced to function in parent package.
108 Operand_2
: Complex_Type
:= Complex
(Int_Type
(Report
.Ident_Int
(10)),
109 Int_Type
(Report
.Ident_Int
(8)));
110 Mul_Res
: Complex_type
:= Complex
(Int_Type
(Report
.Ident_Int
(30)),
111 Int_Type
(Report
.Ident_Int
(16)));
112 Complex_No
: Complex_Type
:= Zero
; -- Zero is declared in parent package.
114 Complex_No
:= Operand_1
* Operand_2
; -- Basic_Complex."*".
115 if Complex_No
/= Mul_Res
then
116 Report
.Failed
("Incorrect results from multiplication");
119 -- Error is raised and exception will be handled.
120 if Complex_No
= Mul_Res
then
121 raise Multiply_Error
; -- Reference to exception in
122 end if; -- parent package.
125 when Multiply_Error
=>
126 TC_Handled_In_Subtest_1
:= true;
128 TC_Handled_In_Subtest_1
:= false; -- Improper exception handling.
130 end Multiply_Complex_Subtest
;
134 Error_In_Client
: exception renames Add_Error
;
135 -- Reference to exception in parent package.
136 Operand_1
: Complex_Type
:= Complex
(Int_Type
(Report
.Ident_Int
(2)),
137 Int_Type
(Report
.Ident_Int
(7)));
138 Operand_2
: Complex_Type
:= Complex
(Int_Type
(Report
.Ident_Int
(-4)),
139 Int_Type
(Report
.Ident_Int
(1)));
140 Add_Res
: Complex_type
:= Complex
(Int_Type
(Report
.Ident_Int
(-2)),
141 Int_Type
(Report
.Ident_Int
(8)));
142 Complex_No
: Complex_Type
:= One
; -- One is declared in parent
145 Complex_No
:= Operand_1
+ Operand_2
; -- Basic_Complex."+".
147 if Complex_No
/= Add_Res
then
148 Report
.Failed
("Incorrect results from multiplication");
151 -- Error is raised and exception will be handled.
152 if Complex_No
= Add_Res
then
153 raise Error_In_Client
;
157 when Error_In_Client
=>
158 TC_Handled_In_Subtest_2
:= true;
161 TC_Handled_In_Subtest_2
:= false; -- Improper exception handling.
163 end Add_Complex_Subtest
;
165 if not (TC_Handled_In_Subtest_1
and -- Check to see that all
166 TC_Handled_In_Subtest_2
) -- exceptions were handled
167 -- in the proper location.
169 Report
.Failed
("Exceptions handled in incorrect locations");