ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/64_glib_04_condvar.t
Revision: 1.8
Committed: Tue Jul 30 23:14:33 2013 UTC (10 years, 10 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-7_05, rel-7_07, rel-7_08, rel-7_09, rel-7_16, rel-7_15, rel-7_14, rel-7_13, rel-7_12, rel-7_11, HEAD
Changes since 1.7: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.2 use AnyEvent;
2 root 1.6
3 root 1.8 BEGIN { $^W = 0 }
4 root 1.6 BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) }
5     BEGIN { eval q{use AnyEvent::Impl::Glib;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Glib not loadable\n}), exit 0) }
6    
7    
8 root 1.1
9 root 1.7 $| = 1; print "1..28\n";
10 root 1.1
11     print "ok 1\n";
12    
13     {
14     my $cv = AnyEvent->condvar;
15    
16     $cv->cb (sub {
17     print $_[0]->ready ? "" : "not ", "ok 4\n";
18    
19     my $x = $_[0]->recv;
20     print $x == 7 ? "" : "not ", "ok 5 # $x == 7\n";
21    
22     my @x = $_[0]->recv;
23     print $x[1] == 5 ? "" : "not ", "ok 6 # $x[1] == 5\n";
24    
25     my $y = $cv->recv;
26     print $y == 7 ? "" : "not ", "ok 7 # $x == 7\n";
27     });
28    
29     my $t = AnyEvent->timer (after => 0, cb => sub {
30     print "ok 3\n";
31     $cv->send (7, 5);
32     });
33    
34     print "ok 2\n";
35 root 1.5 $cv->recv;
36 root 1.1 print "ok 8\n";
37    
38     my @x = $cv->recv;
39     print $x[1] == 5 ? "" : "not ", "ok 9 # $x[1] == 5\n";
40     }
41    
42     {
43     my $cv = AnyEvent->condvar;
44    
45     $cv->cb (sub {
46     print $_[0]->ready ? "" : "not ", "ok 12\n";
47    
48     my $x = eval { $_[0]->recv };
49     print !defined $x ? "" : "not ", "ok 13\n";
50     print $@ =~ /^kill/ ? "" : "not ", "ok 14 # $@\n";
51     });
52    
53     my $t = AnyEvent->timer (after => 0, cb => sub {
54     print "ok 11\n";
55     $cv->croak ("kill");
56     print "ok 15\n";
57     $cv->send (8, 6, 4);
58     print "ok 16\n";
59     });
60    
61     print "ok 10\n";
62     my @x = eval { $cv->recv };
63     print !@x ? "" : "not ", "ok 17 # @x\n";
64     print $@ =~ /^kill / ? "" : "not ", "ok 18 # $@\n";
65     }
66    
67     {
68     my $cv = AnyEvent->condvar;
69    
70     print "ok 19\n";
71     my $t = AnyEvent->timer (after => 0, cb => $cv);
72    
73     print "ok 20\n";
74     $cv->recv;
75     print "ok 21\n";
76     }
77    
78 root 1.7 {
79     my $cv = AE::cv {
80     print +($_[0]->recv)[0] == 6 ? "" : "not ", "ok 27\n";
81     };
82    
83     print "ok 22\n";
84    
85     $cv->begin (sub {
86     print "ok 26\n";
87     $_[0](6);
88     });
89    
90     print "ok 23\n";
91     $cv->begin;
92     print "ok 24\n";
93     $cv->end;
94     print "ok 25\n";
95     $cv->end;
96    
97     print "ok 28\n";
98     }
99