1 |
root |
1.1 |
use AnyEvent; |
2 |
|
|
use AnyEvent::Util; |
3 |
|
|
|
4 |
root |
1.3 |
BEGIN { $^W = 0 } |
5 |
root |
1.1 |
BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) } |
6 |
root |
1.2 |
BEGIN { eval q{use AnyEvent::Impl::FLTK;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::FLTK not loadable\n}), exit 0) } |
7 |
root |
1.1 |
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
$| = 1; print "1..18\n"; |
11 |
|
|
|
12 |
|
|
print "ok 1\n"; |
13 |
|
|
|
14 |
|
|
my ($a, $b) = AnyEvent::Util::portable_socketpair; |
15 |
|
|
|
16 |
|
|
print $a && $b ? "" : "not ", "ok 2 # $a,$b\n"; |
17 |
|
|
|
18 |
|
|
my ($cv, $t, $ra, $wa, $rb, $wb); |
19 |
|
|
|
20 |
|
|
$rb = AnyEvent->io (fh => $b, poll => "r", cb => sub { |
21 |
|
|
print "ok 6\n"; |
22 |
|
|
sysread $b, my $buf, 1; |
23 |
|
|
print "ok 7\n"; |
24 |
|
|
$wb = AnyEvent->io (fh => $b, poll => "w", cb => sub { |
25 |
|
|
print "ok 8\n"; |
26 |
|
|
undef $wb; |
27 |
|
|
syswrite $b, "1"; |
28 |
|
|
}); |
29 |
|
|
}); |
30 |
|
|
|
31 |
|
|
print "ok 3\n"; |
32 |
|
|
|
33 |
|
|
{ my $cv = AnyEvent->condvar; $t = AnyEvent->timer (after => 0.05, cb => sub { $cv->send }); $cv->recv } |
34 |
|
|
|
35 |
|
|
print "ok 4\n"; |
36 |
|
|
|
37 |
|
|
$wa = AnyEvent->io (fh => $a, poll => "w", cb => sub { |
38 |
|
|
syswrite $a, "0"; |
39 |
|
|
undef $wa; |
40 |
|
|
print "ok 5\n"; |
41 |
|
|
}); |
42 |
|
|
|
43 |
|
|
$ra = AnyEvent->io (fh => $a, poll => "r", cb => sub { |
44 |
|
|
sysread $a, my $buf, 1; |
45 |
|
|
print "ok 9\n"; |
46 |
|
|
$cv->send; |
47 |
|
|
}); |
48 |
|
|
|
49 |
|
|
$cv = AnyEvent->condvar; $cv->recv; |
50 |
|
|
|
51 |
|
|
print "ok 10\n"; |
52 |
|
|
|
53 |
|
|
$rb = AnyEvent->io (fh => fileno $b, poll => "r", cb => sub { |
54 |
|
|
print "ok 14\n"; |
55 |
|
|
sysread $b, my $buf, 1; |
56 |
|
|
print "ok 15\n"; |
57 |
|
|
$wb = AnyEvent->io (fh => fileno $b, poll => "w", cb => sub { |
58 |
|
|
print "ok 16\n"; |
59 |
|
|
undef $wb; |
60 |
|
|
syswrite $b, "1"; |
61 |
|
|
}); |
62 |
|
|
}); |
63 |
|
|
|
64 |
|
|
print "ok 11\n"; |
65 |
|
|
|
66 |
|
|
{ my $cv = AnyEvent->condvar; $t = AnyEvent->timer (after => 0.05, cb => sub { $cv->send }); $cv->recv } |
67 |
|
|
|
68 |
|
|
print "ok 12\n"; |
69 |
|
|
|
70 |
|
|
$wa = AnyEvent->io (fh => fileno $a, poll => "w", cb => sub { |
71 |
|
|
syswrite $a, "0"; |
72 |
|
|
undef $wa; |
73 |
|
|
print "ok 13\n"; |
74 |
|
|
}); |
75 |
|
|
|
76 |
|
|
$ra = AnyEvent->io (fh => $a, poll => "r", cb => sub { |
77 |
|
|
sysread $a, my $buf, 1; |
78 |
|
|
print "ok 17\n"; |
79 |
|
|
$cv->send; |
80 |
|
|
}); |
81 |
|
|
|
82 |
|
|
$cv = AnyEvent->condvar; $cv->recv; |
83 |
|
|
|
84 |
|
|
print "ok 18\n"; |
85 |
|
|
|