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