ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/AnyEvent-Fork-RPC/t/01_sync.t
Revision: 1.4
Committed: Sun Apr 28 14:34:40 2013 UTC (13 years, 4 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_2, rel-1_24, rel-1_21, rel-1_22, rel-1_23, HEAD
Changes since 1.3: +3 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 $| = 1;
2     print "1..13\n";
3    
4     use AnyEvent;
5 root 1.4 # explicit version on next line, as some cpan-testers test with the 0.1 version,
6     # ignoring dependencies, and this line will at least give a clear indication of that.
7     use AnyEvent::Fork 0.6; # we don't actually depend on it, this is for convenience
8 root 1.1 use AnyEvent::Fork::RPC;
9    
10     print "ok 1\n";
11    
12     my $done = AE::cv;
13    
14     my $rpc = AnyEvent::Fork
15     ->new
16     ->eval (do { local $/; <DATA> })
17     ->AnyEvent::Fork::RPC::run ("run",
18     on_error => sub { print "Bail out! $_[0]\n"; exit 1 },
19     on_event => sub { print "$_[0]\n" },
20     on_destroy => $done,
21     );
22    
23     print "ok 2\n";
24    
25     for (3..6) {
26     $rpc->($_ * 2 - 1, sub { print $_[0] });
27     }
28    
29     print "ok 3\n";
30    
31     undef $rpc;
32    
33     print "ok 4\n";
34    
35     $done->recv;
36    
37     print "ok 13\n";
38    
39     __DATA__
40    
41     sub run {
42     my ($count) = @_;
43    
44     AnyEvent::Fork::RPC::event ("ok $count");
45    
46     "ok " . ($count + 1) . "\n"
47     }
48