1 |
720 |
jeremybenn |
-- C341A01.A
|
2 |
|
|
--
|
3 |
|
|
-- Grant of Unlimited Rights
|
4 |
|
|
--
|
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
|
14 |
|
|
-- 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 |
|
|
--
|
26 |
|
|
-- OBJECTIVE:
|
27 |
|
|
-- Check that formal parameters of a class-wide type can be passed
|
28 |
|
|
-- values of any specific type within the class.
|
29 |
|
|
--
|
30 |
|
|
-- TEST DESCRIPTION:
|
31 |
|
|
-- Define an object of a root tagged type and of various types derived
|
32 |
|
|
-- from the root. Define objects of the root class, and initialize them
|
33 |
|
|
-- by parameter association of objects of the specific types (root and
|
34 |
|
|
-- extended types) within the class.
|
35 |
|
|
--
|
36 |
|
|
-- The particular root and extended types used in this abstraction are
|
37 |
|
|
-- defined in foundation code (F341A00.A), and are graphically displayed
|
38 |
|
|
-- as follows:
|
39 |
|
|
--
|
40 |
|
|
-- package Bank
|
41 |
|
|
-- type Account
|
42 |
|
|
-- |
|
43 |
|
|
-- |
|
44 |
|
|
-- |
|
45 |
|
|
-- package Checking
|
46 |
|
|
-- type Account
|
47 |
|
|
-- |
|
48 |
|
|
-- |
|
49 |
|
|
-- |
|
50 |
|
|
-- package Interest_Checking
|
51 |
|
|
-- type Account
|
52 |
|
|
--
|
53 |
|
|
--
|
54 |
|
|
-- TEST FILES:
|
55 |
|
|
-- This test depends on the following foundation code:
|
56 |
|
|
--
|
57 |
|
|
-- F341A00.A
|
58 |
|
|
--
|
59 |
|
|
-- The following files comprise this test:
|
60 |
|
|
--
|
61 |
|
|
-- => C341A01.A
|
62 |
|
|
--
|
63 |
|
|
--
|
64 |
|
|
-- CHANGE HISTORY:
|
65 |
|
|
-- 06 Dec 94 SAIC ACVC 2.0
|
66 |
|
|
--
|
67 |
|
|
--!
|
68 |
|
|
|
69 |
|
|
with F341A00_0; -- package Bank
|
70 |
|
|
with F341A00_1; -- package Checking
|
71 |
|
|
with F341A00_2; -- package Interest_Checking
|
72 |
|
|
with Report;
|
73 |
|
|
|
74 |
|
|
procedure C341A01 is
|
75 |
|
|
|
76 |
|
|
package Bank renames F341A00_0;
|
77 |
|
|
use type Bank.Dollar_Amount;
|
78 |
|
|
package Checking renames F341A00_1;
|
79 |
|
|
package Interest_Checking renames F341A00_2;
|
80 |
|
|
|
81 |
|
|
Max_Accts : constant := 3;
|
82 |
|
|
Bank_Balance : Bank.Dollar_Amount := 0.00;
|
83 |
|
|
|
84 |
|
|
-- Initialize objects of specific tagged types.
|
85 |
|
|
B_Acct : Bank.Account := (Current_Balance => 10.00);
|
86 |
|
|
C_Acct : Checking.Account := (100.00, 10.00);
|
87 |
|
|
IC_Acct : Interest_Checking.Account := (1000.00, 10.00, 0.030);
|
88 |
|
|
|
89 |
|
|
-- Define and initialize (by parameter association) objects of class-wide
|
90 |
|
|
-- type originating from the root type (Bank.Account).
|
91 |
|
|
|
92 |
|
|
-- Define an account auditing procedure with a class-wide
|
93 |
|
|
-- variable that can hold a value of any object within the class.
|
94 |
|
|
procedure Audit (Next_Account : Bank.Account'Class) is
|
95 |
|
|
begin
|
96 |
|
|
Bank_Balance := Bank_Balance + Next_Account.Current_Balance;
|
97 |
|
|
end Audit;
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
begin -- C341A01
|
101 |
|
|
|
102 |
|
|
Report.Test ("C341A01", "Check that objects of a class-wide type can " &
|
103 |
|
|
"be initialized, by direct assignment, to a " &
|
104 |
|
|
"value of any specific type within the class" );
|
105 |
|
|
|
106 |
|
|
-- Perform nightly audit of total funds on deposit in bank.
|
107 |
|
|
Audit (B_Acct);
|
108 |
|
|
Audit (C_Acct);
|
109 |
|
|
Audit (IC_Acct);
|
110 |
|
|
|
111 |
|
|
if Bank_Balance /= 1110.00 then
|
112 |
|
|
Report.Failed ("Class-wide object processing failed");
|
113 |
|
|
end if;
|
114 |
|
|
|
115 |
|
|
Report.Result;
|
116 |
|
|
|
117 |
|
|
end C341A01;
|