root/t/unspecced/async-sleep.t

Revision 21719, 0.8 kB (checked in by lwall, 5 months ago)

[STD] detect obsolete use of =cut
[t/*.t] delete obsolete uses of =cut

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5=begin kwid
6
7= DESCRIPTION
8
9This test tests the interaction of C<async {}> and
10C<sleep>. Ideally, while a C<sleep> call is in progress
11in one thread, other C<async> blocks are still being
12executed.
13
14=end kwid
15
16plan 1;
17diag "Running under $*OS";
18
19my @events;
20my $event_count = 2;
21
22sub spawn_counter () {
23  async {
24    my $count = $event_count;
25    while ($count--) {
26      push @events, time();
27      sleep 1; # five seconds are enough for everybody
28    };
29  };
30};
31
32diag "This test will take about " ~ ($event_count+2) ~ " seconds.";
33
34spawn_counter();
35sleep $event_count+2;
36
37if (!ok(@events == $event_count, "Our async counter finished while we were sleeping")) {
38  diag "Got      " ~ +@events ~ " element(s).";
39  diag "Expected $event_count elements."
40};
Note: See TracBrowser for help on using the browser.