ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/62_cocoa_04_condvar.t
Revision: 1.4
Committed: Fri Aug 12 18:41:27 2011 UTC (13 years, 4 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-6_0
Changes since 1.3: +5 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 use AnyEvent;
2
3 BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) }
4 BEGIN { eval q{use AnyEvent::Impl::Cocoa;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Cocoa not loadable\n}), exit 0) }
5
6
7
8 $| = 1; print "1..21\n";
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->recv;
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 => $cv);
71
72 print "ok 20\n";
73 $cv->recv;
74 print "ok 21\n";
75 }
76