1 |
$|=1; |
2 |
BEGIN { |
3 |
print "1..21\n" |
4 |
} |
5 |
|
6 |
use AnyEvent; |
7 |
use AnyEvent::Impl::EventLib; |
8 |
|
9 |
print "ok 1\n"; |
10 |
|
11 |
{ |
12 |
my $cv = AnyEvent->condvar; |
13 |
|
14 |
$cv->cb (sub { |
15 |
print $_[0]->ready ? "" : "not ", "ok 4\n"; |
16 |
|
17 |
my $x = $_[0]->recv; |
18 |
print $x == 7 ? "" : "not ", "ok 5 # $x == 7\n"; |
19 |
|
20 |
my @x = $_[0]->recv; |
21 |
print $x[1] == 5 ? "" : "not ", "ok 6 # $x[1] == 5\n"; |
22 |
|
23 |
my $y = $cv->recv; |
24 |
print $y == 7 ? "" : "not ", "ok 7 # $x == 7\n"; |
25 |
}); |
26 |
|
27 |
my $t = AnyEvent->timer (after => 0, cb => sub { |
28 |
print "ok 3\n"; |
29 |
$cv->send (7, 5); |
30 |
}); |
31 |
|
32 |
print "ok 2\n"; |
33 |
$cv->wait; |
34 |
print "ok 8\n"; |
35 |
|
36 |
my @x = $cv->recv; |
37 |
print $x[1] == 5 ? "" : "not ", "ok 9 # $x[1] == 5\n"; |
38 |
} |
39 |
|
40 |
{ |
41 |
my $cv = AnyEvent->condvar; |
42 |
|
43 |
$cv->cb (sub { |
44 |
print $_[0]->ready ? "" : "not ", "ok 12\n"; |
45 |
|
46 |
my $x = eval { $_[0]->recv }; |
47 |
print !defined $x ? "" : "not ", "ok 13\n"; |
48 |
print $@ =~ /^kill/ ? "" : "not ", "ok 14 # $@\n"; |
49 |
}); |
50 |
|
51 |
my $t = AnyEvent->timer (after => 0, cb => sub { |
52 |
print "ok 11\n"; |
53 |
$cv->croak ("kill"); |
54 |
print "ok 15\n"; |
55 |
$cv->send (8, 6, 4); |
56 |
print "ok 16\n"; |
57 |
}); |
58 |
|
59 |
print "ok 10\n"; |
60 |
my @x = eval { $cv->recv }; |
61 |
print !@x ? "" : "not ", "ok 17 # @x\n"; |
62 |
print $@ =~ /^kill / ? "" : "not ", "ok 18 # $@\n"; |
63 |
} |
64 |
|
65 |
{ |
66 |
my $cv = AnyEvent->condvar; |
67 |
|
68 |
print "ok 19\n"; |
69 |
my $t = AnyEvent->timer (after => 0, cb => $cv); |
70 |
|
71 |
print "ok 20\n"; |
72 |
$cv->recv; |
73 |
print "ok 21\n"; |
74 |
} |
75 |
|