ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/t/07_loop_timer.t
Revision: 1.4
Committed: Thu Oct 21 15:13:43 2010 UTC (13 years, 8 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: EV-rel-4_28, EV-rel-4_29, EV-rel-4_26, EV-rel-4_27, EV-rel-4_25, EV-rel-4_22, EV-rel-4_20, EV-rel-4_21, rel-4_01, rel-4_00, rel-4_03, rel-4_02, EV-rel-4_31, EV-rel-4_30, EV-rel-4_33, EV-rel-4_32, EV-rel-4_34, EV_rel-4_11, EV_rel-4_10, EV-rel-4_15, EV_rel-4_17, EV_rel-4_16, EV-rel-4_18, HEAD
Changes since 1.3: +1 -1 lines
Log Message:
port testsuite

File Contents

# User Rev Content
1 root 1.3 BEGIN {
2     # many testers have totally overloaded machines with virtual machines
3     # running backwards in time etc. etc.
4     if (exists $ENV{AUTOMATED_TESTING}) {
5     print "1..0 # Skipped: Too many broken cpan tester setups.\n";
6     exit;
7     }
8     }
9    
10 root 1.1 BEGIN { $| = 1; print "1..752\n"; }
11    
12     no warnings;
13     use strict;
14    
15     use EV;
16    
17     my $l = new EV::Loop;
18    
19     my $fudge = 0.02; # allow rt and monotonic clock to disagree by this much
20    
21     my $id = 1;
22     my @timer;
23     my @periodic;
24    
25     my $base = $l->now;
26     my $prev = $l->now;
27    
28     for my $i (1..125) {
29     my $t = $i * $i * 1.735435336; $t -= int $t;
30     push @timer, $l->timer ($t, 0, sub {
31     my $now = $_[0]->loop->now;
32    
33     print $now + $fudge >= $prev ? "" : "not ", "ok ", ++$id, " # t0 $i $now + $fudge >= $prev\n";
34     print $now + $fudge >= $base + $t ? "" : "not ", "ok ", ++$id, " # t1 $i $now + $fudge >= $base + $t\n";
35    
36     unless ($id % 3) {
37     $t *= 0.0625;
38     $_[0]->set ($t);
39     $_[0]->start;
40     $t = $now + $t - $base;
41     }
42    
43     $prev = $now;
44     });
45    
46     my $t = $i * $i * 1.375475771; $t -= int $t;
47     push @periodic, $l->periodic ($base + $t, 0, 0, sub {
48     my $now = $l->now;
49    
50     print $now >= $prev ? "" : "not ", "ok ", ++$id, " # p0 $i $now >= $prev\n";
51     print $now >= $base + $t ? "" : "not ", "ok ", ++$id, " # p1 $i $now >= $base + $t\n";
52    
53     unless ($id % 3) {
54     $t *= 1.0625;
55     $_[0]->set ($base + $t);
56     $_[0]->start;
57     }
58    
59     $prev = $now;
60     });
61     }
62    
63 root 1.4 EV::run;
64 root 1.1 print "ok 1\n";
65     $l->loop;
66 root 1.2 print "ok 752\n";
67 root 1.1