annotate gcc/testsuite/ada/acats/tests/c9/c974008.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C974008.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that the abortable part of an asynchronous select statement
kono
parents:
diff changeset
28 -- is not started if the triggering statement is a task entry call, and
kono
parents:
diff changeset
29 -- the entry call is not queued.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- Check that the sequence of statements of the triggering alternative
kono
parents:
diff changeset
32 -- is executed after the abortable part is left.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- TEST DESCRIPTION:
kono
parents:
diff changeset
35 -- Declare a main procedure containing an asynchronous select with a task
kono
parents:
diff changeset
36 -- entry call as triggering statement. Ensure that the task is waiting
kono
parents:
diff changeset
37 -- at the accept statement so the rendezvous is executed immediately (the
kono
parents:
diff changeset
38 -- entry call is not queued).
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- CHANGE HISTORY:
kono
parents:
diff changeset
42 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 --!
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 package C974008_0 is -- Automated teller machine abstraction.
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- Flags for testing purposes:
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 Triggering_Statement_Completed : Boolean := False;
kono
parents:
diff changeset
52 Count : Integer := 1234; -- Global to defeat
kono
parents:
diff changeset
53 -- optimization.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 type Key_Enum is (None, Cancel, Deposit, Withdraw);
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 type Card_Number_Type is private;
kono
parents:
diff changeset
58 type Card_PIN_Type is private;
kono
parents:
diff changeset
59 type ATM_Card_Type is private;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 Transaction_Canceled : exception;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 task type ATM_Keyboard_Task is
kono
parents:
diff changeset
66 entry Cancel_Pressed;
kono
parents:
diff changeset
67 end ATM_Keyboard_Task;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Read_Card (Card : in out ATM_Card_Type);
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 procedure Perform_Transaction (Card : in ATM_Card_Type);
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 private
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 type Card_Number_Type is range 1 .. 9999;
kono
parents:
diff changeset
78 type Card_PIN_Type is range 100 .. 999;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 type ATM_Card_Type is record
kono
parents:
diff changeset
81 Number : Card_Number_Type;
kono
parents:
diff changeset
82 PIN : Card_PIN_Type;
kono
parents:
diff changeset
83 end record;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 end C974008_0;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 --==================================================================--
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 with Report;
kono
parents:
diff changeset
92 package body C974008_0 is
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 procedure Listen_For_Input (Key : out Key_Enum) is
kono
parents:
diff changeset
96 begin
kono
parents:
diff changeset
97 -- Simulate the situation where the user presses the cancel key
kono
parents:
diff changeset
98 -- before the card is validated
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -- press the cancel key immediately
kono
parents:
diff changeset
101 Key := Cancel;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 end Listen_For_Input;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 -- One of these gets created as "Keyboard" for each transaction
kono
parents:
diff changeset
108 --
kono
parents:
diff changeset
109 task body ATM_Keyboard_Task is
kono
parents:
diff changeset
110 Key_Pressed : Key_Enum := None;
kono
parents:
diff changeset
111 begin
kono
parents:
diff changeset
112 -- NOTE: Normal usage for this routine would be the loop with
kono
parents:
diff changeset
113 -- the select statement included. This particular test
kono
parents:
diff changeset
114 -- requires that the task be waiting at the accept
kono
parents:
diff changeset
115 -- for the call. To ensure that this is the case the
kono
parents:
diff changeset
116 -- extraneous commands are commented out (we leave them
kono
parents:
diff changeset
117 -- in this form to show the reader the surrounds to the
kono
parents:
diff changeset
118 -- fragment of code remaining)
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 -- loop
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 Listen_For_Input (Key_Pressed);
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 -- select
kono
parents:
diff changeset
125 -- when (Key_Pressed = Cancel) => -- Guard is now
kono
parents:
diff changeset
126 accept Cancel_Pressed do -- true, so accept
kono
parents:
diff changeset
127 Triggering_Statement_Completed := True; -- queued entry
kono
parents:
diff changeset
128 end Cancel_Pressed; -- call.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 -- User has cancelled the transaction so we exit the
kono
parents:
diff changeset
131 -- loop and allow the task to terminate
kono
parents:
diff changeset
132 -- exit;
kono
parents:
diff changeset
133 -- else
kono
parents:
diff changeset
134 -- Key_Pressed := None;
kono
parents:
diff changeset
135 -- end select;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- end loop;
kono
parents:
diff changeset
138 exception
kono
parents:
diff changeset
139 when others =>
kono
parents:
diff changeset
140 Report.Failed ("Unexpected Exception in ATM_Keyboard_Task");
kono
parents:
diff changeset
141 end ATM_Keyboard_Task;
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Read_Card (Card : in out ATM_Card_Type) is
kono
parents:
diff changeset
146 begin
kono
parents:
diff changeset
147 Card.Number := 9999;
kono
parents:
diff changeset
148 Card.PIN := 111;
kono
parents:
diff changeset
149 end Read_Card;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 procedure Perform_Transaction (Card : in ATM_Card_Type) is
kono
parents:
diff changeset
153 begin
kono
parents:
diff changeset
154 Report.Failed ("Triggering alternative sequence of statements " &
kono
parents:
diff changeset
155 "not executed");
kono
parents:
diff changeset
156 if not Triggering_Statement_Completed then
kono
parents:
diff changeset
157 Report.Failed ("Triggering statement did not complete");
kono
parents:
diff changeset
158 end if;
kono
parents:
diff changeset
159 end Perform_Transaction;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 end C974008_0;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 --==================================================================--
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 with Report;
kono
parents:
diff changeset
169 with ImpDef;
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 with C974008_0; -- Automated teller machine abstraction.
kono
parents:
diff changeset
172 use C974008_0;
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 procedure C974008 is
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 Card_Data : ATM_Card_Type;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 begin -- Main program.
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 Report.Test ("C974008", "Asynchronous Select: Trigger is a call to a " &
kono
parents:
diff changeset
181 "waiting task entry and completes immediately");
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 Read_Card (Card_Data);
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 declare
kono
parents:
diff changeset
186 -- Create the task for this transaction
kono
parents:
diff changeset
187 Keyboard : C974008_0.ATM_Keyboard_Task;
kono
parents:
diff changeset
188 begin
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 -- Ensure task is waiting at the accept
kono
parents:
diff changeset
191 -- This is the time required to activate another task and allow it
kono
parents:
diff changeset
192 -- to run to its first accept statement.
kono
parents:
diff changeset
193 --
kono
parents:
diff changeset
194 delay ImpDef.Switch_To_New_Task;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 -- --
kono
parents:
diff changeset
197 -- Asynchronous select is tested here --
kono
parents:
diff changeset
198 -- --
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 select
kono
parents:
diff changeset
201 Keyboard.Cancel_Pressed; -- Entry call is executed immediately
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 raise Transaction_Canceled; -- This is executed after Validate_Card
kono
parents:
diff changeset
204 -- is aborted.
kono
parents:
diff changeset
205 then abort
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 -- In other similar tests Validate_Card is called here. In this
kono
parents:
diff changeset
208 -- test we just check to see if the abortable part is called at
kono
parents:
diff changeset
209 -- all. Since the triggering call is not queued the abortable
kono
parents:
diff changeset
210 -- part should not be started
kono
parents:
diff changeset
211 --
kono
parents:
diff changeset
212 Report.Failed ("Abortable part started");
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 end select;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 Perform_Transaction (Card_Data); -- Should not be reached.
kono
parents:
diff changeset
217 exception
kono
parents:
diff changeset
218 when Transaction_Canceled =>
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 if not Triggering_Statement_Completed then
kono
parents:
diff changeset
221 Report.Failed ("Triggering alternative sequence of statements " &
kono
parents:
diff changeset
222 "executed but triggering statement not complete");
kono
parents:
diff changeset
223 end if;
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 end;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 Report.Result;
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 end C974008;