ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/67_tk_04_condvar.t
Revision: 1.2
Committed: Sat Jul 18 00:05:29 2009 UTC (14 years, 10 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_85
Changes since 1.1: +3 -6 lines
Log Message:
*** empty log message ***

File Contents

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