ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/handle/01_readline.t
Revision: 1.1
Committed: Sun Apr 27 16:56:17 2008 UTC (16 years, 2 months ago) by elmex
Content type: application/x-troff
Branch: MAIN
Log Message:
added IO::AnyEvent as AnyEvent::Handle and AnyEvent::Socket, including tests

File Contents

# Content
1 #!perl
2 use strict;
3 use AnyEvent::Handle;
4 use Test::More tests => 1;
5 use Socket;
6
7 my $cv = AnyEvent->condvar;
8
9 socketpair my $rd, my $wr, AF_UNIX, SOCK_STREAM, PF_UNSPEC;
10
11 my $rd_ae = AnyEvent::Handle->new (fh => $rd);
12
13 my $line_cnt = 3;
14 my $concat;
15
16 $rd_ae->readlines (sub {
17 my ($rd_ae, @lines) = @_;
18 for (@lines) {
19 chomp;
20 $line_cnt--;
21 $concat .= $_;
22 }
23 if ($line_cnt <= 0) { $cv->broadcast }
24 });
25
26 $wr->syswrite ("A\nBC\nDEF\nG\n");
27 $wr->syswrite (("X" x 113) . "\n");
28
29 $cv->wait;
30
31 is ($concat, "ABCDEFG".("X"x113), 'lines were read correctly');