line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Pattern; |
2
|
168
|
|
|
168
|
|
1162
|
use strict; |
|
168
|
|
|
|
|
339
|
|
|
168
|
|
|
|
|
5493
|
|
3
|
168
|
|
|
168
|
|
875
|
use warnings; |
|
168
|
|
|
|
|
333
|
|
|
168
|
|
|
|
|
4214
|
|
4
|
|
|
|
|
|
|
|
5
|
168
|
|
|
168
|
|
841
|
use base 'Test2::Compare::Base'; |
|
168
|
|
|
|
|
461
|
|
|
168
|
|
|
|
|
17337
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
8
|
|
|
|
|
|
|
|
9
|
168
|
|
|
168
|
|
1211
|
use Test2::Util::HashBase qw/pattern stringify_got/; |
|
168
|
|
|
|
|
340
|
|
|
168
|
|
|
|
|
1085
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Overloads '!' for us. |
12
|
168
|
|
|
168
|
|
26553
|
use Test2::Compare::Negatable; |
|
168
|
|
|
|
|
377
|
|
|
168
|
|
|
|
|
943
|
|
13
|
|
|
|
|
|
|
|
14
|
168
|
|
|
168
|
|
1041
|
use Carp qw/croak/; |
|
168
|
|
|
|
|
360
|
|
|
168
|
|
|
|
|
41847
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
800
|
|
|
800
|
0
|
10397
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
800
|
100
|
|
|
|
4354
|
croak "'pattern' is a required attribute" unless $self->{+PATTERN}; |
20
|
|
|
|
|
|
|
|
21
|
799
|
|
100
|
|
|
3006
|
$self->{+STRINGIFY_GOT} ||= 0; |
22
|
|
|
|
|
|
|
|
23
|
799
|
|
|
|
|
2309
|
$self->SUPER::init(); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
22
|
|
|
22
|
1
|
108
|
sub name { shift->{+PATTERN} . "" } |
27
|
22
|
100
|
|
22
|
1
|
75
|
sub operator { shift->{+NEGATE} ? '!~' : '=~' } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub verify { |
30
|
845
|
|
|
845
|
1
|
1522
|
my $self = shift; |
31
|
845
|
|
|
|
|
2328
|
my %params = @_; |
32
|
845
|
|
|
|
|
2036
|
my ($got, $exists) = @params{qw/got exists/}; |
33
|
|
|
|
|
|
|
|
34
|
845
|
100
|
|
|
|
1808
|
return 0 unless $exists; |
35
|
843
|
100
|
|
|
|
1722
|
return 0 unless defined($got); |
36
|
841
|
100
|
100
|
|
|
2064
|
return 0 if ref $got && !$self->stringify_got; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $got !~ $self->{+PATTERN} |
39
|
839
|
100
|
|
|
|
2082
|
if $self->{+NEGATE}; |
40
|
|
|
|
|
|
|
|
41
|
825
|
|
|
|
|
8357
|
return $got =~ $self->{+PATTERN}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |