-- C392A01.A
|
-- C392A01.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 the use of a class-wide formal parameter allows for the
|
-- Check that the use of a class-wide formal parameter allows for the
|
-- proper dispatching of objects to the appropriate implementation of
|
-- proper dispatching of objects to the appropriate implementation of
|
-- a primitive operation. Check this for the root tagged type defined
|
-- a primitive operation. Check this for the root tagged type defined
|
-- in a package, and the extended type is defined in that same package.
|
-- in a package, and the extended type is defined in that same package.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- Declare a root tagged type, and some associated primitive operations.
|
-- Declare a root tagged type, and some associated primitive operations.
|
-- Extend the root type, and override one or more primitive operations,
|
-- Extend the root type, and override one or more primitive operations,
|
-- inheriting the other primitive operations from the root type.
|
-- inheriting the other primitive operations from the root type.
|
-- Derive from the extended type, again overriding some primitive
|
-- Derive from the extended type, again overriding some primitive
|
-- operations and inheriting others (including some that the parent
|
-- operations and inheriting others (including some that the parent
|
-- inherited).
|
-- inherited).
|
-- Define a subprogram with a class-wide parameter, inside of which is a
|
-- Define a subprogram with a class-wide parameter, inside of which is a
|
-- call on a dispatching primitive operation. These primitive operations
|
-- call on a dispatching primitive operation. These primitive operations
|
-- modify global variables (the class-wide parameter has mode IN).
|
-- modify global variables (the class-wide parameter has mode IN).
|
--
|
--
|
--
|
--
|
--
|
--
|
-- The following hierarchy of tagged types and primitive operations is
|
-- The following hierarchy of tagged types and primitive operations is
|
-- utilized in this test:
|
-- utilized in this test:
|
--
|
--
|
-- type Bank_Account (root)
|
-- type Bank_Account (root)
|
-- |
|
-- |
|
-- | Operations
|
-- | Operations
|
-- | Increment_Bank_Reserve
|
-- | Increment_Bank_Reserve
|
-- | Assign_Representative
|
-- | Assign_Representative
|
-- | Increment_Counters
|
-- | Increment_Counters
|
-- | Open
|
-- | Open
|
-- |
|
-- |
|
-- type Savings_Account (extended from Bank_Account)
|
-- type Savings_Account (extended from Bank_Account)
|
-- |
|
-- |
|
-- | Operations
|
-- | Operations
|
-- | (Increment_Bank_Reserve) (inherited)
|
-- | (Increment_Bank_Reserve) (inherited)
|
-- | Assign_Representative (overridden)
|
-- | Assign_Representative (overridden)
|
-- | Increment_Counters (overridden)
|
-- | Increment_Counters (overridden)
|
-- | Open (overridden)
|
-- | Open (overridden)
|
-- |
|
-- |
|
-- type Preferred_Account (extended from Savings_Account)
|
-- type Preferred_Account (extended from Savings_Account)
|
-- |
|
-- |
|
-- | Operations
|
-- | Operations
|
-- | (Increment_Bank_Reserve) (inherited twice - Bank_Acct.)
|
-- | (Increment_Bank_Reserve) (inherited twice - Bank_Acct.)
|
-- | (Assign_Representative) (inherited - Savings_Acct.)
|
-- | (Assign_Representative) (inherited - Savings_Acct.)
|
-- | Increment_Counters (overridden)
|
-- | Increment_Counters (overridden)
|
-- | Open (overridden)
|
-- | Open (overridden)
|
--
|
--
|
--
|
--
|
-- In this test, we are concerned with the following selection of dispatching
|
-- In this test, we are concerned with the following selection of dispatching
|
-- calls, accomplished with the use of a Bank_Account'Class IN procedure
|
-- calls, accomplished with the use of a Bank_Account'Class IN procedure
|
-- parameter :
|
-- parameter :
|
--
|
--
|
-- \ Type
|
-- \ Type
|
-- Prim. Op \ Bank_Account Savings_Account Preferred_Account
|
-- Prim. Op \ Bank_Account Savings_Account Preferred_Account
|
-- \------------------------------------------------
|
-- \------------------------------------------------
|
-- Increment_Bank_Reserve| X X X
|
-- Increment_Bank_Reserve| X X X
|
-- Assign_Representative | X
|
-- Assign_Representative | X
|
-- Increment_Counters | X X X
|
-- Increment_Counters | X X X
|
--
|
--
|
--
|
--
|
--
|
--
|
-- The location of the declaration and derivation of the root and extended
|
-- The location of the declaration and derivation of the root and extended
|
-- types will be varied over a series of tests. Locations of declaration
|
-- types will be varied over a series of tests. Locations of declaration
|
-- and derivation for a particular test are marked with an asterisk (*).
|
-- and derivation for a particular test are marked with an asterisk (*).
|
--
|
--
|
-- Root type:
|
-- Root type:
|
--
|
--
|
-- * Declared in package.
|
-- * Declared in package.
|
-- Declared in generic package.
|
-- Declared in generic package.
|
--
|
--
|
-- Extended types:
|
-- Extended types:
|
--
|
--
|
-- * Derived in parent location.
|
-- * Derived in parent location.
|
-- Derived in a nested package.
|
-- Derived in a nested package.
|
-- Derived in a nested subprogram.
|
-- Derived in a nested subprogram.
|
-- Derived in a nested generic package.
|
-- Derived in a nested generic package.
|
-- Derived in a separate package.
|
-- Derived in a separate package.
|
-- Derived in a separate visible child package.
|
-- Derived in a separate visible child package.
|
-- Derived in a separate private child package.
|
-- Derived in a separate private child package.
|
--
|
--
|
-- Primitive Operations:
|
-- Primitive Operations:
|
--
|
--
|
-- * Procedures with same parameter profile.
|
-- * Procedures with same parameter profile.
|
-- Procedures with different parameter profile.
|
-- Procedures with different parameter profile.
|
-- Functions with same parameter profile.
|
-- Functions with same parameter profile.
|
-- Functions with different parameter profile.
|
-- Functions with different parameter profile.
|
-- Mixture of Procedures and Functions.
|
-- Mixture of Procedures and Functions.
|
--
|
--
|
--
|
--
|
-- TEST FILES:
|
-- TEST FILES:
|
-- This test depends on the following foundation code:
|
-- This test depends on the following foundation code:
|
--
|
--
|
-- F392A00.A
|
-- F392A00.A
|
--
|
--
|
-- The following files comprise this test:
|
-- The following files comprise this test:
|
--
|
--
|
-- => C392A01.A
|
-- => C392A01.A
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
--
|
--
|
--!
|
--!
|
|
|
with F392A00; -- package Accounts
|
with F392A00; -- package Accounts
|
with Report;
|
with Report;
|
|
|
procedure C392A01 is
|
procedure C392A01 is
|
|
|
package Accounts renames F392A00;
|
package Accounts renames F392A00;
|
|
|
-- Declare account objects.
|
-- Declare account objects.
|
|
|
B_Account : Accounts.Bank_Account;
|
B_Account : Accounts.Bank_Account;
|
S_Account : Accounts.Savings_Account;
|
S_Account : Accounts.Savings_Account;
|
P_Account : Accounts.Preferred_Account;
|
P_Account : Accounts.Preferred_Account;
|
|
|
-- Procedures to operate on accounts.
|
-- Procedures to operate on accounts.
|
-- Each uses a class-wide IN parameter, as well as a call to a
|
-- Each uses a class-wide IN parameter, as well as a call to a
|
-- dispatching operation.
|
-- dispatching operation.
|
|
|
-- Procedure Tabulate_Account performs a dispatching call on a primitive
|
-- Procedure Tabulate_Account performs a dispatching call on a primitive
|
-- operation that has been overridden for each of the extended types.
|
-- operation that has been overridden for each of the extended types.
|
|
|
procedure Tabulate_Account (Acct : in Accounts.Bank_Account'Class) is
|
procedure Tabulate_Account (Acct : in Accounts.Bank_Account'Class) is
|
begin
|
begin
|
Accounts.Increment_Counters (Acct); -- Dispatch according to tag.
|
Accounts.Increment_Counters (Acct); -- Dispatch according to tag.
|
end Tabulate_Account;
|
end Tabulate_Account;
|
|
|
|
|
-- Procedure Accumulate_Reserve performs a dispatching call on a
|
-- Procedure Accumulate_Reserve performs a dispatching call on a
|
-- primitive operation that has been defined for the root type and
|
-- primitive operation that has been defined for the root type and
|
-- inherited by each derived type.
|
-- inherited by each derived type.
|
|
|
procedure Accumulate_Reserve (Acct : in Accounts.Bank_Account'Class) is
|
procedure Accumulate_Reserve (Acct : in Accounts.Bank_Account'Class) is
|
begin
|
begin
|
Accounts.Increment_Bank_Reserve (Acct); -- Dispatch according to tag.
|
Accounts.Increment_Bank_Reserve (Acct); -- Dispatch according to tag.
|
end Accumulate_Reserve;
|
end Accumulate_Reserve;
|
|
|
|
|
-- Procedure Resolve_Dispute performs a dispatching call on a primitive
|
-- Procedure Resolve_Dispute performs a dispatching call on a primitive
|
-- operation that has been defined in the root type, overridden in the
|
-- operation that has been defined in the root type, overridden in the
|
-- first derived extended type, and inherited by the subsequent extended
|
-- first derived extended type, and inherited by the subsequent extended
|
-- type.
|
-- type.
|
|
|
procedure Resolve_Dispute (Acct : in Accounts.Bank_Account'Class) is
|
procedure Resolve_Dispute (Acct : in Accounts.Bank_Account'Class) is
|
begin
|
begin
|
Accounts.Assign_Representative (Acct); -- Dispatch according to tag.
|
Accounts.Assign_Representative (Acct); -- Dispatch according to tag.
|
end Resolve_Dispute;
|
end Resolve_Dispute;
|
|
|
|
|
|
|
begin -- Main test procedure.
|
begin -- Main test procedure.
|
|
|
Report.Test ("C392A01", "Check that the use of a class-wide parameter " &
|
Report.Test ("C392A01", "Check that the use of a class-wide parameter " &
|
"allows for proper dispatching where root type " &
|
"allows for proper dispatching where root type " &
|
"and extended types are declared in the same " &
|
"and extended types are declared in the same " &
|
"package" );
|
"package" );
|
|
|
Bank_Account_Subtest:
|
Bank_Account_Subtest:
|
declare
|
declare
|
use Accounts;
|
use Accounts;
|
begin
|
begin
|
Accounts.Open (B_Account);
|
Accounts.Open (B_Account);
|
|
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- operation that has been defined for this specific type.
|
-- operation that has been defined for this specific type.
|
Accumulate_Reserve (Acct => B_Account);
|
Accumulate_Reserve (Acct => B_Account);
|
Tabulate_Account (B_Account);
|
Tabulate_Account (B_Account);
|
|
|
if (Accounts.Bank_Reserve /= Accounts.Opening_Balance) or
|
if (Accounts.Bank_Reserve /= Accounts.Opening_Balance) or
|
(Accounts.Number_Of_Accounts (Bank) /= 1) or
|
(Accounts.Number_Of_Accounts (Bank) /= 1) or
|
(Accounts.Number_Of_Accounts (Total) /= 1)
|
(Accounts.Number_Of_Accounts (Total) /= 1)
|
then
|
then
|
Report.Failed ("Failed in Bank_Account_Subtest");
|
Report.Failed ("Failed in Bank_Account_Subtest");
|
end if;
|
end if;
|
|
|
end Bank_Account_Subtest;
|
end Bank_Account_Subtest;
|
|
|
|
|
Savings_Account_Subtest:
|
Savings_Account_Subtest:
|
declare
|
declare
|
use Accounts;
|
use Accounts;
|
begin
|
begin
|
Accounts.Open (Acct => S_Account);
|
Accounts.Open (Acct => S_Account);
|
|
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- operation that has been inherited by this extended type.
|
-- operation that has been inherited by this extended type.
|
Accumulate_Reserve (Acct => S_Account);
|
Accumulate_Reserve (Acct => S_Account);
|
|
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- operation that has been overridden for this extended type.
|
-- operation that has been overridden for this extended type.
|
Resolve_Dispute (Acct => S_Account);
|
Resolve_Dispute (Acct => S_Account);
|
Tabulate_Account (S_Account);
|
Tabulate_Account (S_Account);
|
|
|
if Accounts.Bank_Reserve /= (3.0 * Accounts.Opening_Balance) or
|
if Accounts.Bank_Reserve /= (3.0 * Accounts.Opening_Balance) or
|
Accounts.Daily_Representative /= Accounts.Manager or
|
Accounts.Daily_Representative /= Accounts.Manager or
|
Accounts.Number_Of_Accounts (Savings) /= 1 or
|
Accounts.Number_Of_Accounts (Savings) /= 1 or
|
Accounts.Number_Of_Accounts (Total) /= 2
|
Accounts.Number_Of_Accounts (Total) /= 2
|
then
|
then
|
Report.Failed ("Failed in Savings_Account_Subtest");
|
Report.Failed ("Failed in Savings_Account_Subtest");
|
end if;
|
end if;
|
|
|
end Savings_Account_Subtest;
|
end Savings_Account_Subtest;
|
|
|
|
|
Preferred_Account_Subtest:
|
Preferred_Account_Subtest:
|
declare
|
declare
|
use Accounts;
|
use Accounts;
|
begin
|
begin
|
Accounts.Open (P_Account);
|
Accounts.Open (P_Account);
|
|
|
-- Verify that the correct implementation of Open (overridden) was
|
-- Verify that the correct implementation of Open (overridden) was
|
-- used for the Preferred_Account object.
|
-- used for the Preferred_Account object.
|
if not Accounts.Verify_Open (P_Account) then
|
if not Accounts.Verify_Open (P_Account) then
|
Report.Failed ("Incorrect values for init. Preferred Acct object");
|
Report.Failed ("Incorrect values for init. Preferred Acct object");
|
end if;
|
end if;
|
|
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- operation that has been twice inherited by this extended type.
|
-- operation that has been twice inherited by this extended type.
|
Accumulate_Reserve (Acct => P_Account);
|
Accumulate_Reserve (Acct => P_Account);
|
|
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- Demonstrate class-wide parameter allowing dispatch by a primitive
|
-- operation that has been overridden for this extended type (the
|
-- operation that has been overridden for this extended type (the
|
-- operation was overridden by its parent type as well).
|
-- operation was overridden by its parent type as well).
|
Tabulate_Account (P_Account);
|
Tabulate_Account (P_Account);
|
|
|
if Accounts.Bank_Reserve /= 1300.00 or
|
if Accounts.Bank_Reserve /= 1300.00 or
|
Accounts.Number_Of_Accounts (Preferred) /= 1 or
|
Accounts.Number_Of_Accounts (Preferred) /= 1 or
|
Accounts.Number_Of_Accounts (Total) /= 3
|
Accounts.Number_Of_Accounts (Total) /= 3
|
then
|
then
|
Report.Failed ("Failed in Preferred_Account_Subtest");
|
Report.Failed ("Failed in Preferred_Account_Subtest");
|
end if;
|
end if;
|
|
|
end Preferred_Account_Subtest;
|
end Preferred_Account_Subtest;
|
|
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end C392A01;
|
end C392A01;
|
|
|
|
|