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.5 by root, Sat Nov 17 01:52:50 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines