blib/lib/Plack/Test.pm

filter: Statementstmt 94.5% 35 / 37 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 4 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 81.1% 56 / 69 CC 7 SCAR 10.7
CC
7
Cov
82%
test_psgi
5.1
create
3.1
BEGIN
1.0
CRAP 2.9
« blib/lib/Plack/Middleware/ContentLength.pm ↑ Summary blib/lib/Plack/Handler/Apache2/Registry.pm »
1 package Plack::Test;
2 75 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 75 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 75 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 75 ▶use parent qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 75 our @EXPORT = qw(test_psgi);
7  
8 75 our $Impl;
9 75 ▶$Impl ||= $ENV{PLACK_TEST_IMPL} || "MockHTTP";
Condition40%2/5
$Plack::Test::Impl ||= $ENV{"PLACK_TEST_IMPL"} || "MockHTTP"
l!l&&r!l&&!r
0750
$ENV{'PLACK_TEST_IMPL'} || 'MockHTTP'
l!l
075
MC/DC0%0/2
$Plack::Test::Impl ||= $ENV{"PLACK_TEST_IMPL"} || "MockHTTP"
$Plack::Test::Impl $ENV{'PLACK_TEST_IMPL'}
Truth table0%0/3
A ||= B
A= $Plack::Test::ImplB= $ENV{'PLACK_TEST_IMPL'}
ABresult
1X1
011
000
10  
11 130 ▶sub create {
Subroutine create: called CC=3 SCAR=11.4
Pod documented
12 130 my($class, $app, @args) = @_;
13  
14 130 my $subclass = "Plack::Test::$Impl";
15 130 eval "require $subclass";
16 130 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 130 130
17  
18 75 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 130 ▶ if (defined &{"Plack::Test::$Impl\::test_psgi"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined &{"Plack::Test::$Plack::Test::Impl::test_psgi";}) 0 130 130
20 0 return \&{"Plack::Test::$Impl\::test_psgi"};
21 }
22  
23 130 $subclass->new($app, @args);
24 }
25  
26 129 ▶sub test_psgi {
Subroutine test_psgi: called CC=5 SCAR=16.3
Pod documented
27 129 ▶ if (ref $_[0] && @_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] and @_ == 2) 89 40 129
Condition66%2/3
ref $_[0] and @_ == 2
!ll&&!rl&&r
40089
MC/DC50%1/2
ref $_[0] and @_ == 2
ref $_[0] @_ == 2
Truth table66%2/3
A and B
A= ref $_[0]B= @_ == 2
ABresult
0X0
100
111
28 89 @_ = (app => $_[0], client => $_[1]);
29 }
30 129 my %args = @_;
31  
32 129 my $app = delete $args{app}; # Backward compat: some implementations don't need app
33 129 ▶ my $client = delete $args{client} or Carp::croak "client test code needed";
Branch: 1 branch
BranchTrueFalseTotal
my $client = delete $args{"client"} or Carp::croak("client test code needed") 129 0 129
34  
35 129 my $tester = Plack::Test->create($app, %args);
36 129 ▶ return $tester->(@_) if ref $tester eq 'CODE'; # compatibility
Branch: 1 branch
BranchTrueFalseTotal
if ref $tester eq "CODE" 0 129 129
37  
38 129 ▶ $client->(sub { $tester->request(@_) });
Subroutine __ANON__: called CC=1 SCAR=0.0
39 }
40  
41 75 1;
42  
43 __END__
« blib/lib/Plack/Middleware/ContentLength.pm ↑ Summary blib/lib/Plack/Handler/Apache2/Registry.pm »