| 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
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | chomp $error if $error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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"
MC/DC0%0/1
$desc ||= "exact match for trimmed content"
$desc
Truth table50%1/2
A
A= $desc
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | if(defined $error && length $error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $error and length $error
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
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $desc .= (defined $error && length $error ? " (Error: $error)" : ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $error and length $error
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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||