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 subprogram references may be passed as parameters using
28 -- access-to-subprogram types. Check that the passed subprograms may
29 -- be invoked from within the called subprogram.
32 -- Declare an access to function type in a package specification.
33 -- Declare three different trig functions that can be referred to by
34 -- the access to function type.
36 -- In the main program, call each function indirectly by passing the
37 -- access to subprogram value as parameter.
41 -- 06 Dec 94 SAIC ACVC 2.0
46 package Integrate_Lookup
is
48 TC_Log_Call
: Boolean := False;
50 TC_Cos_Call
: Boolean := False;
52 TC_Sine_Call
: Boolean := False;
54 -- Type accesses to functions Log, Sine, or Cos
55 type Integrand_Ptr
is access function
56 (Angle
: Float) return Float;
58 function Log
(Angle
: in Float) return Float;
60 function Sine
(Angle
: in Float) return Float;
62 function Cos
(Angle
: in Float) return Float;
64 function Integrate
(Func
: Integrand_Ptr
; From
, To
: Float)
70 -----------------------------------------------------------------------------
73 package body Integrate_Lookup
is
76 function Log
(Angle
: in Float) return Float is
83 function Sine
(Angle
: in Float) return Float is
90 function Cos
(Angle
: in Float) return Float is
97 function Integrate
(Func
: Integrand_Ptr
; From
, To
: Float)
101 -- calls the actual subprogram passed as parameter
102 Theta
:= Func
(From
) + Func
(To
);
106 end Integrate_Lookup
;
109 -----------------------------------------------------------------------------
114 with Integrate_Lookup
;
122 Report
.Test
("C3A0008", "Check that subprogram references may be passed "
123 & "as parameters using access-to-subprogram types. "
124 & "Check that the passed subprograms may be invoked "
125 & "from within the called subprogram");
127 Area
:= Integrate_Lookup
.Integrate
128 (Integrate_Lookup
.Log
'Access, 1.0, 2.0);
130 If not Integrate_Lookup
.TC_Log_Call
or Area
/= 0.2 then
131 Report
.Failed
("Incorrect Log result");
134 Area
:= Integrate_Lookup
.Integrate
135 (Integrate_Lookup
.Sine
'Access, 1.0, 2.0);
137 If not Integrate_Lookup
.TC_Sine_Call
or Area
/= 0.0 then
138 Report
.Failed
("Incorrect Sine result");
141 Area
:= Integrate_Lookup
.Integrate
142 (Integrate_Lookup
.Cos
'Access, 1.0, 2.0);
144 If not Integrate_Lookup
.TC_Cos_Call
or Area
/= 2.0 then
145 Report
.Failed
("Incorrect Cos result");