ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/68_poe_04_condvar.t
Revision: 1.6
Committed: Mon Jul 4 21:14:29 2011 UTC (12 years, 11 months ago) by root
Content type: application/x-troff
Branch: MAIN
Changes since 1.5: +2 -1 lines
Log Message:
*** empty log message ***

File Contents

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