blib/lib/Plack/Test/Server.pm

filter: Statementstmt 90.2% 37 / 41 Branchbran 0.0% 0 / 2 Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 3 totaltotal 73.9% 51 / 69 CC 5 SCAR 8.1
CC
5
Cov
80%
__ANON__
6.0
request
3.2
new
2.8
CRAP 2.3
« blib/lib/Plack/Request.pm ↑ Summary blib/lib/Plack/MIME.pm »
1 package Plack::Test::Server;
2 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Test::TCP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Plack::Loader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Plack::LWPish;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶sub new {
Subroutine new: called CC=2 SCAR=10.3
Pod undocumented
12 11 my($class, $app, %args) = @_;
13  
14 11 ▶ my $host = $args{host} || '127.0.0.1';
Condition50%1/2
$args{'host'} || '127.0.0.1'
l!l
011
MC/DC0%0/1
$args{'host'} || '127.0.0.1'
$args{'host'}
Truth table50%1/2
A
A= $args{'host'}
Aresult
11
00
15 my $server = Test::TCP->new(
16 listen => $args{listen},
17 host => $host,
18 0 ▶ code => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
19 0 my $sock_or_port = shift;
20 my $server = Plack::Loader->auto(
21 ($args{listen} ? (
22 0 ▶ listen_sock => $sock_or_port,
Branch: 1 branch
BranchTrueFalseTotal
$args{'listen'} ? : 0 0 0
23 ):(
24 port => $sock_or_port,
25 host => $host,
26 ))
27 );
28 0 $server->run($app);
29 0 exit;
30 },
31 11 );
32  
33 11 bless { server => $server, %args }, $class;
34 }
35  
36 15 ▶sub port {
Subroutine port: called CC=1 SCAR=0.0
Pod undocumented
37 15 my $self = shift;
38 15 $self->{server}->port;
39 }
40  
41 15 ▶sub request {
Subroutine request: called CC=3 SCAR=11.6
Pod undocumented
42 15 my($self, $req) = @_;
43  
44 15 ▶ my $ua = $self->{ua} || Plack::LWPish->new( no_proxy => [qw/127.0.0.1/] );
Condition33%1/3
$self->{'ua'} || 'Plack::LWPish'->new('no_proxy', ['127.0.0.1'])
l!l&&r!l&&!r
0150
MC/DC0%0/2
$self->{'ua'} || 'Plack::LWPish'->new('no_proxy', ['127.0.0.1'])
$self->{'ua'} 'Plack::LWPish'->new('no_proxy', ['127.0.0.1'])
Truth table33%1/3
A || B
A= $self->{'ua'}B= 'Plack::LWPish'->new('no_proxy', ['127.0.0.1'])
ABresult
1X1
011
000
45  
46 15 $req->uri->scheme('http');
47 15 ▶ $req->uri->host($self->{host} || '127.0.0.1');
Condition50%1/2
$self->{'host'} || '127.0.0.1'
l!l
015
MC/DC0%0/1
$self->{'host'} || '127.0.0.1'
$self->{'host'}
Truth table50%1/2
A
A= $self->{'host'}
Aresult
11
00
48 15 $req->uri->port($self->port);
49  
50 15 return $ua->request($req);
51 }
52  
53 10 1;
54  
55 __END__
« blib/lib/Plack/Request.pm ↑ Summary blib/lib/Plack/MIME.pm »