ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/t/01_timer.t
(Generate patch)

Comparing EV/t/01_timer.t (file contents):
Revision 1.2 by root, Sat Nov 17 01:41:33 2007 UTC vs.
Revision 1.3 by root, Sat Nov 17 01:48:49 2007 UTC

1BEGIN { $| = 1; print "1..3002\n"; } 1BEGIN { $| = 1; print "1..6002\n"; }
2
3no warnings;
2 4
3use EV; 5use EV;
4 6
5my $id = 1; 7my $id = 1;
6my @timer; 8my @timer;
9my @periodic;
7 10
8my $base = EV::now; 11my $base = EV::now;
9my $prev = EV::now; 12my $prev = EV::now;
10 13
11for (1..1000) { 14for (1..1000) {
12 my $t = $_ * $_ * 1.735435336; $t -= int $t; 15 my $t = $_ * $_ * 1.735435336; $t -= int $t;
13 push @timer, EV::timer $t, 0, sub { 16 push @timer, EV::timer $t, 0, sub {
14 print EV::now >= $prev ? "" : "not ", "ok ", ++$id, " # a ", EV::now, " >= ", $prev, "\n"; 17 my $now = EV::now;
15 print EV::now >= $base + $t ? "" : "not ", "ok ", ++$id, " # b ", EV::now, " >= ", $base + $t, "\n";
16 18
17 $prev = EV::now; 19 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $now >= $prev\n";
20 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $now >= $base + $t\n";
18 21
19 unless ($id % 3) { 22 unless ($id % 3) {
23 $t *= 0.0625;
20 $_[0]->set ($t * 0.0625); 24 $_[0]->set ($t);
25 $_[0]->start;
26 $t = $now + $t - $base;
27 }
28
29 $prev = $now;
30 };
31
32 my $t = $_ * $_ * 1.375475771; $t -= int $t;
33 push @periodic, EV::periodic $base + $t, 0, 0, sub {
34 my $now = EV::now;
35
36 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $now >= $prev\n";
37 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $now >= $base + $t\n";
38
39 unless ($id % 3) {
21 $t *= 1.0625; 40 $t *= 1.0625;
41 $_[0]->set ($base + $t);
22 $_[0]->start; 42 $_[0]->start;
23 } 43 }
44
45 $prev = $now;
24 }; 46 };
25} 47}
26 48
27print "ok 1\n"; 49print "ok 1\n";
28EV::loop; 50EV::loop;
29print "ok 3002\n"; 51print "ok 6002\n";
30 52

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines