|
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 | |
|---|
| 1 | use v6; |
|---|
| 2 | |
|---|
| 3 | use Test; |
|---|
| 4 | |
|---|
| 5 | =begin kwid |
|---|
| 6 | |
|---|
| 7 | = DESCRIPTION |
|---|
| 8 | |
|---|
| 9 | This test tests the interaction of C<async {}> and |
|---|
| 10 | C<sleep>. Ideally, while a C<sleep> call is in progress |
|---|
| 11 | in one thread, other C<async> blocks are still being |
|---|
| 12 | executed. |
|---|
| 13 | |
|---|
| 14 | =end kwid |
|---|
| 15 | |
|---|
| 16 | plan 1; |
|---|
| 17 | diag "Running under $*OS"; |
|---|
| 18 | |
|---|
| 19 | my @events; |
|---|
| 20 | my $event_count = 2; |
|---|
| 21 | |
|---|
| 22 | sub 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 | |
|---|
| 32 | diag "This test will take about " ~ ($event_count+2) ~ " seconds."; |
|---|
| 33 | |
|---|
| 34 | spawn_counter(); |
|---|
| 35 | sleep $event_count+2; |
|---|
| 36 | |
|---|
| 37 | if (!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 | }; |
|---|