summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/timer_cancel.adb
blob: c300b47a859eb6610482ef56dd0c38552113142f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- { dg-do run }

with Ada.Real_Time.Timing_Events;
use Ada.Real_Time, Ada.Real_Time.Timing_Events;

procedure Timer_Cancel is

   E : Timing_Event;
   C : Boolean;

   protected Dummy is
      procedure Trigger (Event : in out Timing_Event);
   end Dummy;

   protected body Dummy is
      procedure Trigger (Event : in out Timing_Event) is
      begin
         null;
      end Trigger;
   end Dummy;

begin
   Set_Handler (E, Time_Last, Dummy.Trigger'Unrestricted_Access);

   if Time_Of_Event (E) /= Time_Last then
      raise Program_Error with "Event time not set correctly";
   end if;

   Cancel_Handler (E, C);

   if not C then
      raise Program_Error with "Event triggered already";
   end if;

   if Time_Of_Event (E) /= Time_First then
      raise Program_Error with "Event time not reset correctly";
   end if;
end Timer_Cancel;