1 | #!perl |
1 | #!perl |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
|
|
4 | |
4 | use AnyEvent::Impl::Perl; |
5 | use AnyEvent::Impl::Perl; |
5 | use AnyEvent::Handle; |
6 | use AnyEvent::Handle; |
6 | use Test::More tests => 3; |
7 | use Test::More tests => 4; |
7 | use Socket; |
8 | use Socket; |
8 | |
9 | |
9 | { |
10 | { |
10 | my $cv = AnyEvent->condvar; |
11 | my $cv = AnyEvent->condvar; |
11 | |
12 | |
… | |
… | |
44 | my $rd_ae = |
45 | my $rd_ae = |
45 | AnyEvent::Handle->new ( |
46 | AnyEvent::Handle->new ( |
46 | fh => $rd, |
47 | fh => $rd, |
47 | on_eof => sub { $cv->broadcast }, |
48 | on_eof => sub { $cv->broadcast }, |
48 | on_read => sub { |
49 | on_read => sub { |
49 | $_[0]->push_read_line (sub { |
50 | $_[0]->push_read (line => sub { |
50 | $concat .= "$_[1]:"; |
51 | $concat .= "$_[1]:"; |
51 | }); |
52 | }); |
52 | } |
53 | } |
53 | ); |
54 | ); |
54 | |
55 | |
55 | my $wr_ae = new AnyEvent::Handle fh => $wr, on_eof => sub { die }; |
56 | my $wr_ae = new AnyEvent::Handle fh => $wr, on_eof => sub { die }; |
56 | |
57 | |
|
|
58 | $wr_ae->push_write (netstring => "0:xx,,"); |
57 | $wr_ae->push_write ("A\nBC\nDEF\nG\n" . ("X" x 113) . "\n"); |
59 | $wr_ae->push_write ("A\nBC\nDEF\nG\n" . ("X" x 113) . "\n"); |
58 | undef $wr; |
60 | undef $wr; |
59 | undef $wr_ae; |
61 | undef $wr_ae; |
|
|
62 | |
|
|
63 | $rd_ae->push_read (netstring => sub { |
|
|
64 | is ($_[1], "0:xx,,"); |
|
|
65 | }); |
60 | |
66 | |
61 | $cv->wait; |
67 | $cv->wait; |
62 | |
68 | |
63 | is ($concat, "A:BC:DEF:G:" . ("X" x 113) . ":", 'second lines were read correctly'); |
69 | is ($concat, "A:BC:DEF:G:" . ("X" x 113) . ":", 'second lines were read correctly'); |
64 | } |
70 | } |