ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/t/19_handle.t
Revision: 1.1
Committed: Mon Jul 20 23:46:28 2009 UTC (14 years, 10 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-5_16, rel-5_161
Log Message:
5.16

File Contents

# Content
1 $|=1;
2 print "1..4\n";
3
4 # note: the fourth test falls into an infinite loop in older versions of Coro
5
6 use AnyEvent::Util; ();
7
8 use Coro;
9 use Coro::Handle;
10
11 my @sep = ("\n", "e", undef, "");
12 my @ex = (
13 "one\n:two\n:\n:three\n:\n:\n:four\n:\n:\n:five\n:six\n:seven:",
14 "one:\ntwo\n\nthre:e:\n\n\nfour\n\n\nfive:\nsix\nse:ve:n:",
15 "one\ntwo\n\nthree\n\n\nfour\n\n\nfive\nsix\nseven:",
16 "one\ntwo\n\n:three\n\n:four\n\n:five\nsix\nseven:",
17 );
18
19 for my $c (0..3) {
20 my ($R, $W) = AnyEvent::Util::portable_pipe
21 or die "error creating pipe pair: $!";
22
23 $R = unblock $R;
24 $W = unblock $W;
25
26 $W->autoflush(1);
27 async {
28 $W->print("one\ntwo\n\nthree\n\n\nfour\n\n\nfive\nsix\nseven");
29 $W->close;
30 }
31
32 my $p;
33 while (defined(my $i = $R->readline($sep[$c]))) {
34 $p .= $i . ":";
35 }
36
37 $ex[$c] eq $p or
38 print "not ";
39 print "ok " . (1 + $c) . "\n";
40 }