1-- { dg-do run }
2
3with Ada.Real_Time.Timing_Events;
4use Ada.Real_Time, Ada.Real_Time.Timing_Events;
5
6procedure Timer_Cancel is
7
8   E : Timing_Event;
9   C : Boolean;
10
11   protected Dummy is
12      procedure Trigger (Event : in out Timing_Event);
13   end Dummy;
14
15   protected body Dummy is
16      procedure Trigger (Event : in out Timing_Event) is
17      begin
18         null;
19      end Trigger;
20   end Dummy;
21
22begin
23   Set_Handler (E, Time_Last, Dummy.Trigger'Unrestricted_Access);
24
25   if Time_Of_Event (E) /= Time_Last then
26      raise Program_Error with "Event time not set correctly";
27   end if;
28
29   Cancel_Handler (E, C);
30
31   if not C then
32      raise Program_Error with "Event triggered already";
33   end if;
34
35   if Time_Of_Event (E) /= Time_First then
36      raise Program_Error with "Event time not reset correctly";
37   end if;
38end Timer_Cancel;
39