blib/lib/Test/Mojo/Trim.pm

filter: Statementstmt 85.7% 30 / 35 Branchbran 37.5% 3 / 8 Conditioncond 25.0% 2 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 75.0% 6 / 8 Podpod 50.0% 1 / 2 totaltotal 63.6% 42 / 66 CC 8 SCAR 21.7
CC
8
Cov
69%
trimmed_content_is
15.3
__ANON__
2.0
__ANON__
2.0
CRAP 8.8
↑ Summary
1 package Test::Mojo::Trim;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Mojo::DOM;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Mojo::Base 'Test::Mojo';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Mojo::Util 'trim';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Trim strings for Test::Mojo
10 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
11 2 our $VERSION = '0.1000';
12  
13 1 ▶sub trimmed_content_is {
Subroutine trimmed_content_is: called CC=8 SCAR=27.3
Pod documented
14 1 my $self = shift;
15 1 my $value = squish(Mojo::DOM->new(shift)->to_string);
16 1 my $desc = shift;
17  
18 1 my $dom = $self->tx->res->dom;
19 1 my $got = squish($dom->to_string);
20 1 ▶ my $error = defined $dom->at('#error') ? $dom->at('#error')->text : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $dom->at('#error') ? : 0 1 1
21 1 ▶ chomp $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 1 1
22  
23 1 $value =~ s{> <}{><}g;
24 1 $got =~ s{> <}{><}g;
25 1 ▶ $desc ||= 'exact match for trimmed content';
Condition50%1/2
$desc ||= "exact match for trimmed content"
l!l
10
MC/DC0%0/1
$desc ||= "exact match for trimmed content"
$desc
Truth table50%1/2
A
A= $desc
Aresult
11
00
26  
27 1 ▶ if(defined $error && length $error) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $error and length $error) 0 1 1
Condition33%1/3
defined $error and length $error
!ll&&!rl&&r
100
MC/DC0%0/2
defined $error and length $error
defined $error length $error
Truth table33%1/3
A and B
A= defined $errorB= length $error
ABresult
0X0
100
111
28 0 ▶ $desc .= (defined $error && length $error ? " (Error: $error)" : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $error && length $error ? : 0 0 0
Condition0%0/3
defined $error and length $error
!ll&&!rl&&r
000
MC/DC0%0/2
defined $error and length $error
defined $error length $error
Truth table0%0/3
A and B
A= defined $errorB= length $error
ABresult
0X0
100
111
29 0 ▶ my $table = $dom->find('#context table')->each(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 ▶ $desc .= $_->find('td')->map(sub { $_->text })->join(' ');
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 0 });
32 0 $got = '<see error>';
33 }
34  
35 1 return $self->_test('is', $got, $value, $desc);
36 }
37  
38 2 ▶sub squish {
Subroutine squish: called CC=1 SCAR=0.0
Pod undocumented
39 2 my $string = trim @_;
40 2 $string =~ s{\s+}{ }g;
41 2 return $string;
42 }
43  
44 2 1;
45  
46 __END__
↑ Summary