--- EV/t/01_timer.t 2007/11/17 01:48:49 1.3 +++ EV/t/01_timer.t 2010/03/16 20:43:05 1.9 @@ -1,9 +1,21 @@ +BEGIN { + # many testers have totally overloaded machines with virtual machines + # running backwards in time etc. etc. + if (exists $ENV{AUTOMATED_TESTING}) { + print "1..0 # Skipped: Too many broken cpan tester setups.\n"; + exit; + } +} + BEGIN { $| = 1; print "1..6002\n"; } no warnings; +use strict; use EV; +my $fudge = 0.02; # allow rt and monotonic clock to disagree by this much + my $id = 1; my @timer; my @periodic; @@ -11,13 +23,15 @@ my $base = EV::now; my $prev = EV::now; -for (1..1000) { - my $t = $_ * $_ * 1.735435336; $t -= int $t; +for my $i (1..1000) { + my $t = $i * $i * 1.735435336; $t -= int $t; push @timer, EV::timer $t, 0, sub { 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"; + EV::default_loop->verify; + + print $now + $fudge >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now + $fudge >= $prev\n"; + print $now + $fudge >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now + $fudge >= $base + $t\n"; unless ($id % 3) { $t *= 0.0625; @@ -29,12 +43,14 @@ $prev = $now; }; - my $t = $_ * $_ * 1.375475771; $t -= int $t; + my $t = $i * $i * 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"; + EV::default_loop->verify; + + print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $i $now >= $prev\n"; + print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $i $now >= $base + $t\n"; unless ($id % 3) { $t *= 1.0625;