ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/68_poe_04_condvar.t
Revision: 1.2
Committed: Thu Apr 23 22:44:30 2009 UTC (15 years, 1 month ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-4_4, rel-4_45, rel-4_41, rel-4_42, rel-4_412, rel-4_81, rel-4_411, rel-4_8
Changes since 1.1: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

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