1
2
3
4
5
6
7
8
9
|
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
|
|
|
1
2
3
4
5
6
7
8
9
|
------------------------------------------------------------------------------
-- Copyright (c) 2014-2016, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
-----------------------
-- Inidividual Tests --
-----------------------
procedure Basic_Usage (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Basic black-box usage");
Total : constant Duration := 1.0;
Tick : constant Duration := Total / 10;
Half_Tick : constant Duration := Tick / 2;
Log : aliased Bounded_String (256);
begin
declare
Beat : constant Cron_Entry := Create
(Tick, Test_Callback'(Backend => Log'Access, Symbol => '.'));
pragma Unreferenced (Beat);
Test_Entry : Cron_Entry;
begin
delay Half_Tick;
Test_Entry.Set
(Tick, Test_Callback'(Backend => Log'Access, Symbol => '1'));
delay 3 * Tick + Half_Tick;
Test_Entry.Reset;
delay Half_Tick;
end;
Append (Log, '|');
delay Tick / 10;
declare
use type Ada.Calendar.Time;
Beat : constant Cron_Entry := Create
((Origin => Ada.Calendar.Clock + Half_Tick,
Period => Tick),
Test_Callback'(Backend => Log'Access, Symbol => '.'));
pragma Unreferenced (Beat);
Slow, Fast : Cron_Entry;
begin
Slow.Set
(2 * Tick,
Test_Callback'(Backend => Log'Access, Symbol => 's'));
delay 2 * Tick;
|
>
>
|
>
>
>
>
>
<
<
>
>
>
>
>
>
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
-----------------------
-- Inidividual Tests --
-----------------------
procedure Basic_Usage (Report : in out NT.Reporter'Class) is
use type Ada.Calendar.Time;
Test : NT.Test := Report.Item ("Basic black-box usage");
Total : constant Duration := 10.0;
Tick : constant Duration := Total / 10;
Half_Tick : constant Duration := Tick / 2;
Log : aliased Bounded_String (256);
begin
declare
Beat : constant Cron_Entry := Create
(Tick, Test_Callback'(Backend => Log'Access, Symbol => '.'));
pragma Unreferenced (Beat);
One_Time_Entry : constant Cron_Entry := Create
(Ada.Calendar.Clock + Half_Tick,
Test_Callback'(Backend => Log'Access, Symbol => 'o'));
pragma Unreferenced (One_Time_Entry);
Test_Entry : Cron_Entry;
begin
delay Half_Tick;
Test_Entry.Set
(Tick, Test_Callback'(Backend => Log'Access, Symbol => '1'));
delay 3 * Tick + Half_Tick;
Test_Entry.Reset;
delay Half_Tick;
end;
Append (Log, '|');
delay Tick / 10;
declare
Beat : constant Cron_Entry := Create
((Origin => Ada.Calendar.Clock + Half_Tick,
Period => Tick),
Test_Callback'(Backend => Log'Access, Symbol => '.'));
pragma Unreferenced (Beat);
One_Time_Entry : constant Cron_Entry := Create
((Origin => Ada.Calendar.Clock + Tick,
Period => -Half_Tick),
Test_Callback'(Backend => Log'Access, Symbol => 'O'));
pragma Unreferenced (One_Time_Entry);
Slow, Fast : Cron_Entry;
begin
Slow.Set
(2 * Tick,
Test_Callback'(Backend => Log'Access, Symbol => 's'));
delay 2 * Tick;
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
-- Beat: set at 0.0, finalized at 4.5, run at 1.0, 2.0, 3.0, 4.0.
-- Test_Entry: set at 0.5, reset at 4.0, run at 1.5, 2.5, 3.5.
-- Beat: set at 4.5, finalized at 9.5, run at 5.0, 6.0, 7.0, 8.0, 9.0.
-- Slow: set at 4.5, finalized at 9.5, run at 6.5, 8.5.
-- Fast: set at 6.5, reset at 8.0,
-- run at 6.7, 6.9, 7.1, 7.3, 7.5, 7.7, 7.9
Check (Test, Get (Log), ".1.1.1.|..sff.fffff.s.");
exception
when Error : others => Test.Report_Exception (Error);
end Basic_Usage;
procedure Delete_While_Busy (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Delete entry while callback is running");
|
|
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
-- Beat: set at 0.0, finalized at 4.5, run at 1.0, 2.0, 3.0, 4.0.
-- Test_Entry: set at 0.5, reset at 4.0, run at 1.5, 2.5, 3.5.
-- Beat: set at 4.5, finalized at 9.5, run at 5.0, 6.0, 7.0, 8.0, 9.0.
-- Slow: set at 4.5, finalized at 9.5, run at 6.5, 8.5.
-- Fast: set at 6.5, reset at 8.0,
-- run at 6.7, 6.9, 7.1, 7.3, 7.5, 7.7, 7.9
Check (Test, Get (Log), "o.1.1.1.|.O.sff.fffff.s.");
exception
when Error : others => Test.Report_Exception (Error);
end Basic_Usage;
procedure Delete_While_Busy (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Delete entry while callback is running");
|