line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Test; |
2
|
74
|
|
|
74
|
|
2199910
|
use strict; |
|
74
|
|
|
|
|
553
|
|
|
74
|
|
|
|
|
1885
|
|
3
|
74
|
|
|
74
|
|
334
|
use warnings; |
|
74
|
|
|
|
|
111
|
|
|
74
|
|
|
|
|
1732
|
|
4
|
74
|
|
|
74
|
|
318
|
use Carp; |
|
74
|
|
|
|
|
131
|
|
|
74
|
|
|
|
|
4750
|
|
5
|
74
|
|
|
74
|
|
19404
|
use parent qw(Exporter); |
|
74
|
|
|
|
|
14803
|
|
|
74
|
|
|
|
|
381
|
|
6
|
|
|
|
|
|
|
our @EXPORT = qw(test_psgi); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $Impl; |
9
|
|
|
|
|
|
|
$Impl ||= $ENV{PLACK_TEST_IMPL} || "MockHTTP"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub create { |
12
|
128
|
|
|
128
|
1
|
390
|
my($class, $app, @args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
128
|
|
|
|
|
324
|
my $subclass = "Plack::Test::$Impl"; |
15
|
128
|
|
|
|
|
6072
|
eval "require $subclass"; |
16
|
128
|
50
|
|
|
|
669
|
die $@ if $@; |
17
|
|
|
|
|
|
|
|
18
|
74
|
|
|
74
|
|
9043
|
no strict 'refs'; |
|
74
|
|
|
|
|
200
|
|
|
74
|
|
|
|
|
16499
|
|
19
|
128
|
50
|
|
|
|
250
|
if (defined &{"Plack::Test::$Impl\::test_psgi"}) { |
|
128
|
|
|
|
|
910
|
|
20
|
0
|
|
|
|
|
0
|
return \&{"Plack::Test::$Impl\::test_psgi"}; |
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
128
|
|
|
|
|
669
|
$subclass->new($app, @args); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub test_psgi { |
27
|
127
|
100
|
66
|
127
|
1
|
42077
|
if (ref $_[0] && @_ == 2) { |
28
|
89
|
|
|
|
|
296
|
@_ = (app => $_[0], client => $_[1]); |
29
|
|
|
|
|
|
|
} |
30
|
127
|
|
|
|
|
409
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
127
|
|
|
|
|
265
|
my $app = delete $args{app}; # Backward compat: some implementations don't need app |
33
|
127
|
50
|
|
|
|
376
|
my $client = delete $args{client} or Carp::croak "client test code needed"; |
34
|
|
|
|
|
|
|
|
35
|
127
|
|
|
|
|
635
|
my $tester = Plack::Test->create($app, %args); |
36
|
127
|
50
|
|
|
|
675
|
return $tester->(@_) if ref $tester eq 'CODE'; # compatibility |
37
|
|
|
|
|
|
|
|
38
|
127
|
|
|
300
|
|
1150
|
$client->(sub { $tester->request(@_) }); |
|
300
|
|
|
|
|
556481
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |