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.1 by root, Tue Nov 13 02:43:26 2007 UTC vs.
Revision 1.4 by root, Sat Nov 17 01:51:16 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 my $i (1..1000) {
12 my $t = $_ * $_ * 1.735435336; $t -= int $t; 15 my $t = $i * $i * 1.735435336; $t -= int $t;
13 push @timer, EV::timer $t, 0, sub { 16 push @timer, EV::timer $t, 0, sub {
17 my $now = EV::now;
18
14 print EV::now >= $prev ? "" : "not ", "ok ", ++$id, "\n"; 19 print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now >= $prev\n";
15 print EV::now >= $base + $t ? "" : "not ", "ok ", ++$id, "\n"; 20 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now >= $base + $t\n";
16 21
17 unless ($id % 3) { 22 unless ($id % 3) {
23 $t *= 0.0625;
18 $_[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 = $i * $i * 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 $i $now >= $prev\n";
37 print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $i $now >= $base + $t\n";
38
39 unless ($id % 3) {
19 $t *= 1.0625; 40 $t *= 1.0625;
41 $_[0]->set ($base + $t);
20 $_[0]->start; 42 $_[0]->start;
21 } 43 }
44
45 $prev = $now;
22 }; 46 };
23} 47}
24 48
25print "ok 1\n"; 49print "ok 1\n";
26EV::loop; 50EV::loop;
27print "ok 3002\n"; 51print "ok 6002\n";
28 52

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines