Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / ada / acats / tests / c9 / c974001.a
blob04ac93e6d8fe842a414b14f452277d9d531fccc8
1 -- C974001.A
2 --
3 --
4 -- Grant of Unlimited Rights
5 --
6 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
7 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
8 -- unlimited rights in the software and documentation contained herein.
9 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
10 -- this public release, the Government intends to confer upon all
11 -- recipients unlimited rights equal to those held by the Government.
12 -- These rights include rights to use, duplicate, release or disclose the
13 -- released technical data and computer software in whole or in part, in
14 -- any manner and for any purpose whatsoever, and to have or permit others
15 -- to do so.
17 -- DISCLAIMER
19 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
20 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
21 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
22 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
23 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
24 -- PARTICULAR PURPOSE OF SAID MATERIAL.
25 --*
27 -- OBJECTIVE:
28 -- Check that the abortable part of an asynchronous select statement
29 -- is aborted if it does not complete before the triggering statement
30 -- completes, where the triggering statement is a delay_relative
31 -- statement and check that the sequence of statements of the triggering
32 -- alternative is executed after the abortable part is left.
34 -- TEST DESCRIPTION:
35 -- Declare a task with an accept statement containing an asynchronous
36 -- select with a delay_relative triggering statement. Parameterize
37 -- the accept statement with the time to be used in the delay. Simulate a
38 -- time-consuming calculation by declaring a procedure containing an
39 -- infinite loop. Call this procedure in the abortable part.
41 -- The delay will expire before the abortable part completes, at which
42 -- time the abortable part is aborted, and the sequence of statements
43 -- following the triggering statement is executed.
46 -- CHANGE HISTORY:
47 -- 06 Dec 94 SAIC ACVC 2.0
49 --!
51 with Report;
52 with ImpDef;
54 procedure C974001 is
57 --========================================================--
59 -- Medium length delay
60 Allotted_Time : constant Duration := ImpDef.Switch_To_New_Task;
62 Calculation_Canceled : exception;
65 Count : Integer := 1234;
67 procedure Lengthy_Calculation is
68 begin
69 -- Simulate a non-converging calculation.
70 loop -- Infinite loop.
71 Count := (Count + 1) mod 10;
72 delay ImpDef.Minimum_Task_Switch; -- allow other task
73 end loop;
74 end Lengthy_Calculation;
77 --========================================================--
80 task type Timed_Calculation is
81 entry Calculation (Time_Limit : in Duration);
82 end Timed_Calculation;
85 task body Timed_Calculation is
87 begin
88 loop
89 select
90 accept Calculation (Time_Limit : in Duration) do
92 -- --
93 -- Asynchronous select is tested here --
94 -- --
96 select
97 delay Time_Limit; -- Time_Limit is not up yet, so
98 -- Lengthy_Calculation starts.
100 raise Calculation_Canceled; -- This is executed after
101 -- Lengthy_Calculation aborted.
102 then abort
103 Lengthy_Calculation; -- Delay expires before complete,
104 -- so this call is aborted.
106 -- Check that the whole of the abortable part is aborted,
107 -- not just the statement in the abortable part that was
108 -- executing at the time
109 Report.Failed ("Abortable part not aborted");
111 end select;
113 Report.Failed ("Triggering alternative sequence of " &
114 "statements not executed");
116 exception -- New Ada 9x: handler within accept
117 when Calculation_Canceled =>
118 if Count = 1234 then
119 Report.Failed ("Abortable part did not execute");
120 end if;
121 end Calculation;
123 terminate;
124 end select;
125 end loop;
126 exception
127 when others =>
128 Report.Failed ("Unexpected exception in Timed_Calculation task");
129 end Timed_Calculation;
132 --========================================================--
135 begin -- Main program.
137 Report.Test ("C974001", "Asynchronous Select: Trigger is delay_relative" &
138 " which completes before abortable part");
140 declare
141 Timed : Timed_Calculation; -- Task.
142 begin
143 Timed.Calculation (Time_Limit => Allotted_Time); -- Asynchronous select
144 -- inside accept block.
145 exception
146 when Calculation_Canceled =>
147 null; -- expected behavior
148 end;
150 Report.Result;
152 end C974001;