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 class-wide objects can be initialized using allocation.
30 -- Declare access types that refer to class-wide types, one with basis
31 -- of the root type, another with basis of a type extended from the root.
32 -- Declare objects of these access types, and allocate class-wide
33 -- objects, initialized to values of specific types within the particular
36 -- The particular root and extended types used in this abstraction are
37 -- defined in foundation code (F341A00.A), and are graphically displayed
50 -- package Interest_Checking
54 -- This test depends on the following foundation code:
58 -- The following files comprise this test:
64 -- 06 Dec 94 SAIC ACVC 2.0
68 with F341A00_0
; -- package Bank
69 with F341A00_1
; -- package Checking
70 with F341A00_2
; -- package Interest_Checking
75 package Bank
renames F341A00_0
;
76 package Checking
renames F341A00_1
;
77 package Interest_Checking
renames F341A00_2
;
79 use type Bank
.Dollar_Amount
;
81 Max_Accts
: constant := 3;
82 Bank_Balance
: Bank
.Dollar_Amount
:= 0.00;
84 -- Define access types referring to class of types rooted at
85 -- Bank.Account (root).
87 type Bank_Account_Pointer
is access Bank
.Account
'Class;
90 -- Define class-wide objects, initializing them through allocation.
93 -- Initialized to specific type that is basis of class.
94 Bank_Acct
: Bank_Account_Pointer
:=
95 new Bank
.Account
'(Current_Balance => 10.00);
97 -- Initialized to specific type that has been extended from the basis
99 Checking_Acct : Bank_Account_Pointer :=
100 new Checking.Account'(Current_Balance
=> 100.00,
101 Overdraft_Fee
=> 10.00);
103 -- Initialized to specific type that has been twice extended from the
104 -- basis of the class.
105 IC_Acct
: Bank_Account_Pointer
:=
106 new Interest_Checking
.Account
'(Current_Balance => 1000.00,
107 Overdraft_Fee => 10.00,
110 -- Declare and initialize array of pointers to objects of
111 -- Bank.Account'Class.
113 Accounts : array (1 .. Max_Accts) of Bank_Account_Pointer :=
114 (Bank_Acct, Checking_Acct, IC_Acct);
117 -- Audit will process any account object within Bank.Account'Class.
119 function Audit (Ptr : Bank_Account_Pointer) return Bank.Dollar_Amount is
121 return (Ptr.Current_Balance);
127 Report.Test ("C341A04", "Check that class-wide objects were " &
128 "successfully initialized using allocation" );
130 for i in 1 .. Max_Accts loop
131 Bank_Balance := Bank_Balance + Audit (Accounts(i));
134 if Bank_Balance /= 1110.00 then
135 Report.Failed ("Failed class-wide object allocation");