ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/handle/01_readline.t
(Generate patch)

Comparing AnyEvent/t/handle/01_readline.t (file contents):
Revision 1.9 by root, Fri Jun 6 10:49:20 2008 UTC vs.
Revision 1.11 by root, Fri Jun 6 11:05:16 2008 UTC

1#!perl 1#!perl
2
3# actually tests a few other read/write types as well
2 4
3use strict; 5use strict;
4 6
5use AnyEvent::Impl::Perl; 7use AnyEvent::Impl::Perl;
6use AnyEvent::Handle; 8use AnyEvent::Handle;
7use Test::More tests => 7; 9use Test::More tests => 8;
8use Socket; 10use Socket;
11use Errno;
9 12
10{ 13{
11 my $cv = AnyEvent->condvar; 14 my $cv = AnyEvent->condvar;
12 15
13 socketpair my $rd, my $wr, AF_UNIX, SOCK_STREAM, PF_UNSPEC; 16 socketpair my $rd, my $wr, AF_UNIX, SOCK_STREAM, PF_UNSPEC;
14 17
15 my $rd_ae = AnyEvent::Handle->new ( 18 my $rd_ae = AnyEvent::Handle->new (
16 fh => $rd, 19 fh => $rd,
17 on_error => sub { 20 on_error => sub {
18 ok ($! == Errno::EPIPE); 21 ok ($! == &Errno::EPIPE);
19 }, 22 },
20 on_eof => sub { $cv->broadcast }, 23 on_eof => sub { $cv->broadcast },
21 ); 24 );
22 25
23 my $concat; 26 my $concat;
61 undef $wr; 64 undef $wr;
62 undef $rd; 65 undef $rd;
63 66
64 $wr_ae->push_write (netstring => "0:xx,,"); 67 $wr_ae->push_write (netstring => "0:xx,,");
65 $wr_ae->push_write (netstring => ""); 68 $wr_ae->push_write (netstring => "");
69 $wr_ae->push_write (storable => [4,3,2]);
66 $wr_ae->push_write (packstring => "w", "hallole" x 99999); # try to exhaust socket buffer here 70 $wr_ae->push_write (packstring => "w", "hallole" x 99999); # try to exhaust socket buffer here
67 $wr_ae->push_write ("A\nBC\nDEF\nG\n" . ("X" x 113) . "\n"); 71 $wr_ae->push_write ("A\012BC\012DEF\nG\012" . ("X" x 113) . "\012");
68 undef $wr_ae; 72 undef $wr_ae;
69 73
70 $rd_ae->push_read (netstring => sub { is ($_[1], "0:xx,,"); }); 74 $rd_ae->push_read (netstring => sub { is ($_[1], "0:xx,,") });
71 $rd_ae->push_read (netstring => sub { is ($_[1], ""); }); 75 $rd_ae->push_read (netstring => sub { is ($_[1], "") });
76 $rd_ae->push_read (storable => "w", sub { is ("@{$_[1]}", "4 3 2") });
72 $rd_ae->push_read (packstring => "w", sub { is ($_[1], "hallole" x 99999); }); 77 $rd_ae->push_read (packstring => "w", sub { is ($_[1], "hallole" x 99999) });
73 78
74 $cv->wait; 79 $cv->wait;
75 80
76 is ($concat, "A:BC:DEF:G:" . ("X" x 113) . ":", 'second lines were read correctly'); 81 is ($concat, "A:BC:DEF:G:" . ("X" x 113) . ":", 'second set of lines were read correctly');
77} 82}
78 83

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines