ExtDirect/Test/Pkg/Bar.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 5 totaltotal 92.3% 60 / 65 CC 3 SCAR 3.2
CC
3
Cov
100%
bar_baz
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« ExtDirect/Request/PollHandler.pm ↑ Summary ExtDirect/Serialize.pm »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 9 ▶use base 'RPC::ExtDirect::Test::Pkg::Foo';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # Define package scope hooks
23 9 ▶use RPC::ExtDirect BEFORE => \&bar_before, after => \&bar_after;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 # This one croaks merrily
28 9 ▶sub bar_foo : ExtDirect(4) { croak 'bar foo!' }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine bar_foo: called CC=1 SCAR=0.0
Pod undocumented
29  
30 # Return the number of passed arguments
31 9 ▶sub bar_bar : ExtDirect(5) { shift; return scalar @_; }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine bar_bar: called CC=1 SCAR=0.0
Pod undocumented
32  
33 # This is a form handler
34 sub bar_baz : ExtDirect(formHandler, decode_params => [qw/frob guzzard/]) {
35 10 ▶ my ($class, %param) = @_;
Subroutine bar_baz: called CC=3 SCAR=11.0
Pod undocumented
36  
37 # Simulate uploaded file handling
38 10 my $uploads = $param{file_uploads};
39 10 ▶ return \%param unless $uploads;
Branch: 1 branch
BranchTrueFalseTotal
unless $uploads 4 6 10
40  
41 # Return 'uploads' data
42 6 my $response = "The following files were processed:\n";
43 6 for my $upload ( @$uploads ) {
44 12 my $name = $upload->{basename};
45 12 my $type = $upload->{type};
46 12 my $size = $upload->{size};
47  
48 12 $response .= "$name $type $size\n";
49 };
50  
51 6 delete $param{file_uploads};
52 6 $param{upload_response} = $response;
53  
54 6 return \%param;
55 9 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 sub bar_before {
58 10 ▶ return 1;
Subroutine bar_before: called CC=1 SCAR=0.0
Pod undocumented
59 }
60  
61 ▶sub bar_after {
Subroutine bar_after: called CC=1 SCAR=0.0
Pod undocumented
62 }
63  
64 9 1;
« ExtDirect/Request/PollHandler.pm ↑ Summary ExtDirect/Serialize.pm »