File Coverage

blib/lib/RPC/ExtDirect/Test/Pkg/PollProvider.pm
Criterion Covered Total %
statement 37 37 100.0
branch 8 8 100.0
condition n/a
subroutine 12 12 100.0
pod 0 1 0.0
total 57 58 98.2


line stmt bran cond sub pod time code
1             #
2             # WARNING WARNING WARNING
3             #
4             # DO NOT CHANGE ANYTHING IN THIS MODULE. OTHERWISE, A LOT OF API
5             # AND OTHER TESTS MAY BREAK.
6             #
7             # This module is here to test certain behaviors. If you need
8             # to test something else, add another test module.
9             # It's that simple.
10             #
11              
12             package # avoid indexing by the nosy PAUSE
13             TheBug;
14              
15 5     5   15194 use strict;
  5         7  
  5         125  
16 5     5   16 use warnings;
  5         7  
  5         351  
17              
18 1     1   4 sub new { bless { message => $_[1] }, $_[0] }
19 1     1   4 sub result { $_[0] }
20              
21             package
22             RPC::ExtDirect::Test::Pkg::PollProvider;
23              
24 5     5   18 use strict;
  5         12  
  5         100  
25 5     5   18 use warnings;
  5         6  
  5         155  
26 5     5   14 no warnings 'uninitialized';
  5         6  
  5         126  
27              
28 5     5   16 use Carp;
  5         22  
  5         315  
29              
30 5     5   353 use RPC::ExtDirect;
  5         6  
  5         26  
31 5     5   1841 use RPC::ExtDirect::Event;
  5         11  
  5         708  
32              
33             # This is to control what gets returned
34             our $WHAT_YOURE_HAVING = 'Usual, please';
35              
36             sub foo : ExtDirect( pollHandler ) {
37 7     7 0 10 my ($class) = @_;
38              
39             # There ought to be something more substantive, but...
40 7 100       25 if ( $WHAT_YOURE_HAVING eq 'Usual, please' ) {
    100          
    100          
    100          
41             return (
42 3         15 RPC::ExtDirect::Event->new('foo_event', [ 'foo' ]),
43             RPC::ExtDirect::Event->new('bar_event', { foo => 'bar' }),
44             );
45             }
46              
47             elsif ( $WHAT_YOURE_HAVING eq 'Ein kaffe bitte' ) {
48             return (
49 1         3 RPC::ExtDirect::Event->new('coffee',
50             'Uno cappuccino, presto!'),
51             );
52             }
53              
54             elsif ( $WHAT_YOURE_HAVING eq 'Whiskey, straight away!' ) {
55 1         146 croak "Burp!";
56             }
57              
58             elsif ( $WHAT_YOURE_HAVING eq "Hey man! There's a roach in my soup!" ) {
59 1         5 my $bug = new TheBug 'TIGER ROACH!! WHOA!';
60 1         4 return $bug;
61             }
62              
63             else {
64             # Nothing special to report in our Special News Report!
65 1         3 return ();
66             };
67 5     5   20 }
  5         6  
  5         25  
68              
69             1;