… | |
… | |
16 | |
16 | |
17 | use AnyEvent; |
17 | use AnyEvent; |
18 | use AnyEvent::Util; |
18 | use AnyEvent::Util; |
19 | BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} } |
19 | BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} } |
20 | |
20 | |
21 | $| = 1; print "1..14\n"; |
21 | $| = 1; print "1..15\n"; |
22 | |
22 | |
23 | print "ok 1\n"; |
23 | print "ok 1\n"; |
24 | |
24 | |
25 | my ($a, $b) = AnyEvent::Util::portable_socketpair; |
25 | my ($a, $b) = AnyEvent::Util::portable_socketpair; |
26 | |
26 | |
27 | # I/O write |
27 | # I/O write |
28 | { |
28 | { |
29 | my $cv = AE::cv; |
29 | my $cv = AE::cv; |
30 | my $wt = AE::timer 0.1, 0, $cv; |
30 | my $wt = AE::timer 1, 0, $cv; |
31 | my $s = 0; |
31 | my $s = 0; |
32 | |
32 | |
33 | $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 }; |
33 | $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 }; |
34 | $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 }; |
34 | $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 }; |
35 | |
35 | |
… | |
… | |
52 | print $s == 0 ? "" : "not ", "ok 3 # $s\n"; |
52 | print $s == 0 ? "" : "not ", "ok 3 # $s\n"; |
53 | |
53 | |
54 | syswrite $b, "x"; |
54 | syswrite $b, "x"; |
55 | |
55 | |
56 | $cv = AE::cv; |
56 | $cv = AE::cv; |
57 | $wt = AE::timer 0.1, 0, $cv; |
57 | $wt = AE::timer 1, 0, $cv; |
58 | |
58 | |
59 | $s = 0; |
59 | $s = 0; |
60 | $cv->begin; |
60 | $cv->begin; |
61 | $cv->begin; |
61 | $cv->begin; |
62 | $cv->recv; |
62 | $cv->recv; |
… | |
… | |
149 | $cv->recv; |
149 | $cv->recv; |
150 | |
150 | |
151 | print $s == 0 ? "" : "not ", "ok 13 # $s\n"; |
151 | print $s == 0 ? "" : "not ", "ok 13 # $s\n"; |
152 | } |
152 | } |
153 | |
153 | |
|
|
154 | # timers (don't laugh, some event loops are more broken...) |
|
|
155 | { |
|
|
156 | my $cv = AE::cv; |
|
|
157 | my $wt = AE::timer 1, 0, $cv; |
|
|
158 | my $s = 0; |
|
|
159 | |
|
|
160 | $cv->begin; my $wa = AE::timer 0 , 0, sub { $cv->end; $s |= 1 }; |
|
|
161 | $cv->begin; my $wb = AE::timer 0 , 0, sub { $cv->end; $s |= 2 }; |
|
|
162 | $cv->begin; my $wc = AE::timer 0.01, 0, sub { $cv->end; $s |= 4 }; |
|
|
163 | |
|
|
164 | $cv->recv; |
|
|
165 | |
|
|
166 | print $s == 7 ? "" : "not ", "ok 14 # $s\n"; |
|
|
167 | } |
|
|
168 | |
154 | print "ok 14\n"; |
169 | print "ok 15\n"; |
155 | |
170 | |
156 | exit 0; |
171 | exit 0; |
157 | |
172 | |