lib/WWW/Mechanize/Script/Plugin/ContentSizeTest.pm

filter: Statementstmt 69.7% 23 / 33 Branchbran 37.5% 3 / 8 Conditioncond 20.0% 2 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 55.3% 36 / 65 CC 9 SCAR 29.3
CC
9
Cov
55%
check_response
28.5
BEGIN
1.0
BEGIN
1.0
CRAP 18.7
« lib/WWW/Mechanize/Script/Plugin/TextMatchTest.pm ↑ Summary lib/WWW/Mechanize/Script/Plugin.pm »
1 package WWW::Mechanize::Script::Plugin::ContentSizeTest;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use parent qw(WWW::Mechanize::Script::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: check for size of received content
9  
10 2 our $VERSION = '0.100';
11  
12 2 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 sub check_value_names
16 5 ▶{
Subroutine check_value_names: called CC=1 SCAR=0.0
Pod documented
17 5 return qw(min_bytes max_bytes);
18 }
19  
20  
21 sub check_response
22 1 ▶{
Subroutine check_response: called CC=9 SCAR=33.5
Pod documented
23 1 my ( $self, $check, $mech ) = @_;
24  
25 1 my $code = 0;
26 1 my $msg;
27  
28 1 my $min_bytes = 0 + $self->get_check_value( $check, "min_bytes" );
29 1 my $max_bytes = 0 + $self->get_check_value( $check, "max_bytes" );
30 1 my $content_len = length $mech->response()->content();
31  
32 1 ▶ if ( defined($min_bytes) and $min_bytes > $content_len )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $min_bytes and $min_bytes > $content_len) 0 1 1
Condition33%1/3
defined $min_bytes and $min_bytes > $content_len
!ll&&!rl&&r
010
MC/DC0%0/2
defined $min_bytes and $min_bytes > $content_len
defined $min_bytes $min_bytes > $content_len
Truth table33%1/3
A and B
A= defined $min_bytesB= $min_bytes > $content_len
ABresult
0X0
100
111
33 {
34 0 ▶ my $err_code = $self->get_check_value( $check, "min_bytes_code" ) // 1;
Condition0%0/2
$self->get_check_value($check, "min_bytes_code") // 1
l!l
00
MC/DC0%0/1
$self->get_check_value($check, "min_bytes_code") // 1
$self->get_check_value($check, "min_bytes_code")
Truth table0%0/2
A
A= $self->get_check_value($check, "min_bytes_code")
Aresult
11
00
35 0 $code = &{ $check->{compute_code} }( $code, $err_code );
36 0 $msg = "received $content_len bytes exceeds lower threshold ($min_bytes)";
37 }
38  
39 1 ▶ if ( defined($max_bytes) and $max_bytes < $content_len )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $max_bytes and $max_bytes < $content_len) 0 1 1
Condition33%1/3
defined $max_bytes and $max_bytes < $content_len
!ll&&!rl&&r
010
MC/DC0%0/2
defined $max_bytes and $max_bytes < $content_len
defined $max_bytes $max_bytes < $content_len
Truth table33%1/3
A and B
A= defined $max_bytesB= $max_bytes < $content_len
ABresult
0X0
100
111
40 {
41 0 ▶ my $err_code = $self->get_check_value( $check, "max_bytes_code" ) // 1;
Condition0%0/2
$self->get_check_value($check, "max_bytes_code") // 1
l!l
00
MC/DC0%0/1
$self->get_check_value($check, "max_bytes_code") // 1
$self->get_check_value($check, "max_bytes_code")
Truth table0%0/2
A
A= $self->get_check_value($check, "max_bytes_code")
Aresult
11
00
42 0 $code = &{ $check->{compute_code} }( $code, $err_code );
43 0 ▶ if ($msg)
Branch: 1 branch
BranchTrueFalseTotal
if ($msg) { } 0 0 0
44 {
45 0 $msg .= " and upper threshold ($max_bytes )";
46 }
47 else
48 {
49 0 $msg = "received $content_len bytes exceeds upper limit ($max_bytes)";
50 }
51 }
52  
53 1 ▶ return ( $code, ( $msg ? ($msg) : () ) );
Branch: 1 branch
BranchTrueFalseTotal
$msg ? : 0 1 1
54 }
55  
56 2 1;
57  
58 __END__
« lib/WWW/Mechanize/Script/Plugin/TextMatchTest.pm ↑ Summary lib/WWW/Mechanize/Script/Plugin.pm »