File Coverage

blib/lib/RPC/ExtDirect/Test/Pkg/Bar.pm
Criterion Covered Total %
statement 43 43 100.0
branch 2 2 100.0
condition n/a
subroutine 14 14 100.0
pod 0 5 0.0
total 59 64 92.1


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             # This does not need to be indexed by PAUSE
13             package
14             RPC::ExtDirect::Test::Pkg::Bar;
15              
16 9     9   2789 use strict;
  9         9  
  9         197  
17 9     9   27 use warnings;
  9         11  
  9         182  
18 9     9   27 no warnings 'uninitialized';
  9         9  
  9         213  
19              
20 9     9   27 use base 'RPC::ExtDirect::Test::Pkg::Foo';
  9         8  
  9         1364  
21              
22             # Define package scope hooks
23 9     9   32 use RPC::ExtDirect BEFORE => \&bar_before, after => \&bar_after;
  9         9  
  9         154  
24              
25 9     9   30 use Carp;
  9         9  
  9         589  
26              
27             # This one croaks merrily
28 9     9 0 30 sub bar_foo : ExtDirect(4) { croak 'bar foo!' }
  9     1   14  
  9         41  
  1         199  
29              
30             # Return the number of passed arguments
31 9     9 0 1100 sub bar_bar : ExtDirect(5) { shift; return scalar @_; }
  9     1   10  
  9         26  
  1         1  
  1         5  
32              
33             # This is a form handler
34             sub bar_baz : ExtDirect(formHandler, decode_params => [qw/frob guzzard/]) {
35 10     10 0 27 my ($class, %param) = @_;
36              
37             # Simulate uploaded file handling
38 10         13 my $uploads = $param{file_uploads};
39 10 100       36 return \%param unless $uploads;
40              
41             # Return 'uploads' data
42 6         8 my $response = "The following files were processed:\n";
43 6         14 for my $upload ( @$uploads ) {
44 12         18 my $name = $upload->{basename};
45 12         15 my $type = $upload->{type};
46 12         15 my $size = $upload->{size};
47              
48 12         34 $response .= "$name $type $size\n";
49             };
50              
51 6         11 delete $param{file_uploads};
52 6         9 $param{upload_response} = $response;
53              
54 6         22 return \%param;
55 9     9   1778 }
  9         13  
  9         32  
56              
57             sub bar_before {
58 10     10 0 76 return 1;
59             }
60              
61       10 0   sub bar_after {
62             }
63              
64             1;