URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c3/] [c3a0007.a] - Rev 720
Compare with Previous | Blame | View Log
-- C3A0007.A---- Grant of Unlimited Rights---- 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-- unlimited rights in the software and documentation contained herein.-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making-- this public release, the Government intends to confer upon all-- recipients unlimited rights equal to those held by the Government.-- These rights include rights to use, duplicate, release or disclose the-- 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-- to do so.---- DISCLAIMER---- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A-- PARTICULAR PURPOSE OF SAID MATERIAL.--*---- OBJECTIVE:-- Check that a call to a subprogram via an access-to-subprogram value-- stored in a data structure will correctly dispatch according to the-- tag of the class-wide parameter passed via that call.---- TEST DESCRIPTION:-- Declare an access to procedure type in a package specification.-- Declare a root tagged type with the access to procedure type as a-- component. Declare three primitive procedures for the type that-- can be referred to by the access to procedure type. Use the access-- to procedure type to initialize the component of a record.---- Extend the root type with a record extension in another package-- specification. Declare a new primitive procedure for the extension-- (in addition to its three inherited subprograms).---- In the main program, declare an operation for the root tagged type-- which can be passed as an access value to change the initial value-- of the component. Call the inherited operation indirectly by-- dereferencing the access value to check on the initial value of the-- extension. Call inherited operations indirectly by dereferencing-- the access value to replace the initial value. Call the primitive-- procedure indirectly by dereferencing the access value to modify the-- extension.---- type Button-- procedure Push(Button)-- procedure Set_Response(Button,Button_Response_Ptr)-- procedure Default_Response(Button)---- type Priority_Button (new Button)-- procedures Push, Set_Response inherited-- procedure Default_Response-- procedure Set_Priority------ CHANGE HISTORY:-- 06 Dec 94 SAIC ACVC 2.0----!package C3A0007_0 isDefault_Call : Boolean := False;type Button is tagged private;type Button_Response_Ptr is access procedure(B : in out Button'Class);procedure Push (B : in out Button); -- to be inheritedprocedure Set_Response (B : in out Button; -- to be inheritedR : in Button_Response_Ptr);procedure Response (B : in out Button); -- to be inheritedprivateprocedure Default_Response(B: in out Button'Class);type Button is tagged -- root tagged typerecordAction : Button_Response_Ptr:= Default_Response'Access;end record;end C3A0007_0;with C3A0007_0;package C3A0007_1 istype Priority_Button is new C3A0007_0.Buttonwith recordPriority : Integer := 0;end record;-- Inherits procedure Push from Button-- Inherits procedure Set_Response from Button-- Override procedure Response from Buttonprocedure Response (B : in out Priority_Button);-- Primitive operation of the extensionprocedure Set_Priority (B : in out Priority_Button);end C3A0007_1;with C3A0007_0;package C3A0007_2 isEmergency_Call : Boolean := False;procedure Emergency (B : in out C3A0007_0.Button'Class);end C3A0007_2;-----------------------------------------------------------------------------with TCTouch;package body C3A0007_0 isprocedure Push (B : in out Button) isbeginTCTouch.Touch( 'P' ); --------------------------------------------- P-- Invoking subprogram designated by access valueB.Action (B);end Push;procedure Set_Response (B : in out Button;R : in Button_Response_Ptr) isbeginTCTouch.Touch( 'S' ); --------------------------------------------- S-- Set procedure value in recordB.Action := R;end Set_Response;procedure Response (B : in out Button) isbeginTCTouch.Touch( 'D' ); --------------------------------------------- DDefault_Call := True;end Response;procedure Default_Response (B : in out Button'Class) isbeginTCTouch.Touch( 'C' ); --------------------------------------------- CResponse(B);end Default_Response;end C3A0007_0;with TCTouch;package body C3A0007_1 isprocedure Set_Priority (B : in out Priority_Button) isbeginTCTouch.Touch( 's' ); --------------------------------------------- sB.Priority := 1;end Set_Priority;procedure Response (B : in out Priority_Button) isbeginTCTouch.Touch( 'd' ); --------------------------------------------- dend Response;end C3A0007_1;with TCTouch;package body C3A0007_2 isprocedure Emergency (B : in out C3A0007_0.Button'Class) isbeginTCTouch.Touch( 'E' ); ------------------------------------------- EEmergency_Call := True;end Emergency;end C3A0007_2;-----------------------------------------------------------------------------with Report;with TCTouch;with C3A0007_0;with C3A0007_1;with C3A0007_2;procedure C3A0007 isPink_Button : C3A0007_0.Button;Green_Button : C3A0007_1.Priority_Button;beginReport.Test ("C3A0007", "Check that a call to a subprogram via an "& "access-to-subprogram value stored in a data "& "structure will correctly dispatch according to "& "the tag of the class-wide parameter passed "& "via that call" );-- Call inherited operation Push to set Default_Response value-- in the extension.C3A0007_1.Push (Green_Button);TCTouch.Validate("PCd", "First Green Button Push");TCTouch.Assert_Not(C3A0007_0.Default_Call,"Incorrect Green Default_Response");C3A0007_0.Push (Pink_Button);TCTouch.Validate("PCD", "First Pink Button Push");-- Call inherited operations Set_Response and Push to set-- Emergency value in the extension.C3A0007_1.Set_Response (Green_Button, C3A0007_2.Emergency'Access);C3A0007_1.Push (Green_Button);TCTouch.Validate("SPE", "Second Green Button Push");TCTouch.Assert(C3A0007_2.Emergency_Call, "Incorrect Green Emergency");C3A0007_0.Set_Response (Pink_Button, C3A0007_2.Emergency'Access);C3A0007_0.Push (Pink_Button);TCTouch.Validate("SPE", "Second Pink Button Push");-- Call primitive operation to set priority value-- in the extension.C3A0007_1.Set_Priority (Green_Button);TCTouch.Validate("s", "Green Button Priority");TCTouch.Assert(Green_Button.Priority = 1, "Incorrect Set_Priority");Report.Result;end C3A0007;
