2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / ada / acats / tests / c9 / c974014.a
blob03ca915f8968c717dba6d1e1d26a1a0ea1162c21
1 -- C974014.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.
16 -- DISCLAIMER
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 --*
26 -- OBJECTIVE:
27 -- Check that if the triggering alternative of an asynchronous select
28 -- statement is a delay and the abortable part completes before the delay
29 -- expires then the delay is cancelled and the optional statements in the
30 -- triggering part are not performed. In particular, check the case of
31 -- the ATC in non-tasking code.
33 -- TEST DESCRIPTION:
34 -- A fraction of in-line code is simulated. An asynchronous select
35 -- is used with a triggering delay of several minutes. The abortable
36 -- part, which is simulating a very lengthy, time consuming procedure
37 -- actually returns almost immediately thus ensuring that it completes
38 -- first. At the conclusion, if a substantial amount of time has passed
39 -- the delay is assumed not to have been cancelled.
40 -- (based on example in LRM 9.7.4)
43 -- CHANGE HISTORY:
44 -- 06 Dec 94 SAIC ACVC 2.0
46 --!
49 with Report;
50 with Ada.Calendar;
52 procedure C974014 is
54 function "-" (Left, Right : Ada.Calendar.Time)
55 return Duration renames Ada.Calendar."-";
57 TC_Start_Time : Ada.Calendar.Time := Ada.Calendar.Clock;
58 TC_Elapsed_Time : duration;
60 Maximum_Allowable_Time : duration := 300.0; -- for Calculate_Gamma_Function
62 begin
64 Report.Test ("C974014", "ATC: When abortable part completes before " &
65 "a triggering delay, check that the delay " &
66 "is cancelled & optional statements " &
67 "are not performed");
69 declare -- encapsulate test code
71 type Gamma_Index is digits 5; -- float precision
73 -- (These two fields are assumed filled elsewhere)
74 Input_Field, Result_of_Beta : Gamma_Index;
76 -- Notify and take corrective action in the event that
77 -- the procedure Calculate_Gamma_Function does not converge.
79 procedure Non_Convergent is
80 begin
81 null; -- stub
83 Report.Failed ("Optional statements in triggering part" &
84 " were performed");
85 end Non_Convergent;
88 -- This is a very time consuming calculation. It is possible,
89 -- that, with certain parameters, it will not converge. If it
90 -- runs for more than Maximum_Allowable_Time it is considered
91 -- not to be convergent and should be aborted.
93 Procedure Calculate_Gamma_Function (X, Y : Gamma_Index) is
94 begin
95 null; -- Stub
97 end Calculate_Gamma_Function;
99 begin -- declare
101 -- ..... Isolated segment of inline code
103 -- Now Print Gamma Function (abort and display if not convergent)
105 select
106 delay Maximum_Allowable_Time; -- for Calculate_Gamma_Function
107 Non_Convergent; -- Display error and flag result as failed
109 then abort
110 Calculate_Gamma_Function (Input_Field, Result_of_Beta);
111 end select;
113 -- ..... End of Isolated segment of inline code
115 end; -- declare
117 TC_Elapsed_Time := Ada.Calendar.Clock - TC_Start_Time;
119 -- Note: We are not checking for "cancellation within a reasonable time",
120 -- we are checking for cancellation/non-cancellation of the delay. We
121 -- use a number which, if exceeded, means that the delay was not
122 -- cancelled and has proceeded to full term.
124 if ( TC_Elapsed_Time > Maximum_Allowable_Time/2 ) then
125 -- Test time exceeds a reasonable value.
126 Report.Failed ("Triggering delay statement was not cancelled");
127 end if;
130 Report.Result;
132 end C974014;