--- EV/t/01_timer.t 2007/11/17 01:41:33 1.2 +++ EV/t/01_timer.t 2007/11/17 01:48:49 1.3 @@ -1,9 +1,12 @@ -BEGIN { $| = 1; print "1..3002\n"; } +BEGIN { $| = 1; print "1..6002\n"; } + +no warnings; use EV; my $id = 1; my @timer; +my @periodic; my $base = EV::now; my $prev = EV::now; @@ -11,20 +14,39 @@ for (1..1000) { my $t = $_ * $_ * 1.735435336; $t -= int $t; push @timer, EV::timer $t, 0, sub { - print EV::now >= $prev ? "" : "not ", "ok ", ++$id, " # a ", EV::now, " >= ", $prev, "\n"; - print EV::now >= $base + $t ? "" : "not ", "ok ", ++$id, " # b ", EV::now, " >= ", $base + $t, "\n"; + my $now = EV::now; + + print $now >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $now >= $prev\n"; + print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $now >= $base + $t\n"; + + unless ($id % 3) { + $t *= 0.0625; + $_[0]->set ($t); + $_[0]->start; + $t = $now + $t - $base; + } + + $prev = $now; + }; - $prev = EV::now; + my $t = $_ * $_ * 1.375475771; $t -= int $t; + push @periodic, EV::periodic $base + $t, 0, 0, sub { + my $now = EV::now; + + print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $now >= $prev\n"; + print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $now >= $base + $t\n"; unless ($id % 3) { - $_[0]->set ($t * 0.0625); $t *= 1.0625; + $_[0]->set ($base + $t); $_[0]->start; } + + $prev = $now; }; } print "ok 1\n"; EV::loop; -print "ok 3002\n"; +print "ok 6002\n";