Natools

Check-in [757553b10d]
Login
Overview
Comment:cron-tests: add a test for event list extension by a single event
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 757553b10d9f3a84ec9fcf6090df33f28e89e3d2
User & Date: nat on 2017-07-07 20:11:37
Other Links: manifest | tags
Context
2017-07-08
21:30
cron: fix event order when extending an event list check-in: 7064962d3b user: nat tags: trunk
2017-07-07
20:11
cron-tests: add a test for event list extension by a single event check-in: 757553b10d user: nat tags: trunk
2017-07-06
20:51
cron-tests: fix argument order in calls to Check check-in: d1dd5bc62e user: nat tags: trunk
Changes

Modified tests/natools-cron-tests.adb from [c34fd12609] to [4950100b99].

78
79
80
81
82
83
84

85
86
87
88
89
90
91
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92







+







   begin
      Basic_Usage (Report);
      Delete_While_Busy (Report);
      Insert_While_Busy (Report);
      Time_Collision (Report);
      Delete_While_Collision (Report);
      Event_List_Fusion (Report);
      Event_List_Extension (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------
223
224
225
226
227
228
229
























































230
231
232
233
234
235
236
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      Check (Test, "(", Get (Log));
      delay 4 * Tick;
      Check (Test, "()<>", Get (Log));
   exception
      when Error : others => Test.Report_Exception (Error);
   end Delete_While_Collision;


   procedure Event_List_Extension (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Extension of synchronized callbacks");
      Total : constant Duration := 0.25;
      Log : aliased Bounded_String (256);
   begin
      declare
         use type Ada.Calendar.Time;
         First_Tick : constant Periodic_Time
           := (Origin => Ada.Calendar.Clock + Total / 8,
               Period => Total / 2);
         Second_Tick : constant Periodic_Time
           := (Origin => First_Tick.Origin + First_Tick.Period,
               Period => First_Tick.Period);

         Head, Middle, Tail, Extra : Cron_Entry;
      begin
         Head.Set (First_Tick, Long_Callback'
           (Backend => Log'Access,
            Open => '(',
            Close => ')',
            Wait => Total / 4));
         Middle.Set (First_Tick, Test_Callback'
           (Backend => Log'Access,
            Symbol => 'M'));
         Tail.Set (First_Tick, Test_Callback'
           (Backend => Log'Access,
            Symbol => 'T'));

         delay Total / 4;
         Check (Test, "(", Get (Log));

         Extra.Set (Second_Tick, Test_Callback'
           (Backend => Log'Access,
            Symbol => 'E'));
         Middle.Reset;

         delay Total / 4;
         Check (Test, "()MT", Get (Log));

         delay Total / 4;
         Check (Test, "()MTE(", Get (Log));

         delay Total / 4;
         Check (Test, "()MTE()T", Get (Log));
      end;

      --  Timeline:  0   .   1/4   .   1/2   .   3/4   .   1
      --  Log:           (         )MT       E(         )T
      --  Code:      *        *         *         *        *

      Check (Test, "()MTE()T", Get (Log));
   exception
      when Error : others => Test.Report_Exception (Error);
   end Event_List_Extension;


   procedure Event_List_Fusion (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Fusion of synchronized callbacks");
      Total : constant Duration := 0.25;
      Log : aliased Bounded_String (256);
   begin
      declare

Modified tests/natools-cron-tests.ads from [1bfff1ac61] to [6c46bf6eb4].

25
26
27
28
29
30
31

32
33
34
35
36
37
38
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







+







   package NT renames Natools.Tests;

   procedure All_Tests (Report : in out NT.Reporter'Class);

   procedure Basic_Usage (Report : in out NT.Reporter'Class);
   procedure Delete_While_Busy (Report : in out NT.Reporter'Class);
   procedure Delete_While_Collision (Report : in out NT.Reporter'Class);
   procedure Event_List_Extension (Report : in out NT.Reporter'Class);
   procedure Event_List_Fusion (Report : in out NT.Reporter'Class);
   procedure Insert_While_Busy (Report : in out NT.Reporter'Class);
   procedure Time_Collision (Report : in out NT.Reporter'Class);

private

   type Bounded_String (Max_Size : Natural) is record