| 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"
$ENV{'PLACK_TEST_IMPL'} || 'MockHTTP'
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'}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
ref $_[0] and @_ == 2
MC/DC50%1/2
ref $_[0] and @_ == 2
ref $_[0]
@_ == 2
Truth table66%2/3
A and B
A= ref $_[0]B= @_ == 2
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 129 | my $tester = Plack::Test->create($app, %args); | |||||||||||||||||||||||||||
| 36 | 129 | ▶ | return $tester->(@_) if ref $tester eq 'CODE'; # compatibility | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 129 | ▶ | $client->(sub { $tester->request(@_) }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 75 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||