ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/61_fltk_07_io.t
Revision: 1.1
Committed: Fri Aug 12 18:41:26 2011 UTC (13 years, 3 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-6_0, rel-6_01
Log Message:
*** empty log message ***

File Contents

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