ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/64_glib_04_condvar.t
Revision: 1.7
Committed: Thu Aug 18 17:58:53 2011 UTC (12 years, 9 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-7_0, rel-6_1, rel-6_14, rel-6_11, rel-6_12, rel-6_13, rel-7_04, rel-7_01, rel-7_02, rel-7_03, rel-6_02, rel-6_01
Changes since 1.6: +23 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.2 use AnyEvent;
2 root 1.6
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::Glib;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Glib not loadable\n}), exit 0) }
5    
6    
7 root 1.1
8 root 1.7 $| = 1; print "1..28\n";
9 root 1.1
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 root 1.5 $cv->recv;
35 root 1.1 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    
77 root 1.7 {
78     my $cv = AE::cv {
79     print +($_[0]->recv)[0] == 6 ? "" : "not ", "ok 27\n";
80     };
81    
82     print "ok 22\n";
83    
84     $cv->begin (sub {
85     print "ok 26\n";
86     $_[0](6);
87     });
88    
89     print "ok 23\n";
90     $cv->begin;
91     print "ok 24\n";
92     $cv->end;
93     print "ok 25\n";
94     $cv->end;
95    
96     print "ok 28\n";
97     }
98