| 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
| |||||||||||
| 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; | |||||||||