line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Pattern; |
2
|
169
|
|
|
169
|
|
1144
|
use strict; |
|
169
|
|
|
|
|
355
|
|
|
169
|
|
|
|
|
4966
|
|
3
|
169
|
|
|
169
|
|
867
|
use warnings; |
|
169
|
|
|
|
|
356
|
|
|
169
|
|
|
|
|
4409
|
|
4
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
873
|
use base 'Test2::Compare::Base'; |
|
169
|
|
|
|
|
385
|
|
|
169
|
|
|
|
|
18062
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
8
|
|
|
|
|
|
|
|
9
|
169
|
|
|
169
|
|
1168
|
use Test2::Util::HashBase qw/pattern stringify_got/; |
|
169
|
|
|
|
|
342
|
|
|
169
|
|
|
|
|
1125
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Overloads '!' for us. |
12
|
169
|
|
|
169
|
|
27968
|
use Test2::Compare::Negatable; |
|
169
|
|
|
|
|
365
|
|
|
169
|
|
|
|
|
982
|
|
13
|
|
|
|
|
|
|
|
14
|
169
|
|
|
169
|
|
1123
|
use Carp qw/croak/; |
|
169
|
|
|
|
|
358
|
|
|
169
|
|
|
|
|
43603
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
800
|
|
|
800
|
0
|
12290
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
800
|
100
|
|
|
|
5980
|
croak "'pattern' is a required attribute" unless $self->{+PATTERN}; |
20
|
|
|
|
|
|
|
|
21
|
799
|
|
100
|
|
|
3275
|
$self->{+STRINGIFY_GOT} ||= 0; |
22
|
|
|
|
|
|
|
|
23
|
799
|
|
|
|
|
2469
|
$self->SUPER::init(); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
22
|
|
|
22
|
1
|
175
|
sub name { shift->{+PATTERN} . "" } |
27
|
22
|
100
|
|
22
|
1
|
113
|
sub operator { shift->{+NEGATE} ? '!~' : '=~' } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub verify { |
30
|
845
|
|
|
845
|
1
|
1556
|
my $self = shift; |
31
|
845
|
|
|
|
|
2596
|
my %params = @_; |
32
|
845
|
|
|
|
|
2109
|
my ($got, $exists) = @params{qw/got exists/}; |
33
|
|
|
|
|
|
|
|
34
|
845
|
100
|
|
|
|
2052
|
return 0 unless $exists; |
35
|
843
|
100
|
|
|
|
1889
|
return 0 unless defined($got); |
36
|
841
|
100
|
100
|
|
|
2240
|
return 0 if ref $got && !$self->stringify_got; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $got !~ $self->{+PATTERN} |
39
|
839
|
100
|
|
|
|
2722
|
if $self->{+NEGATE}; |
40
|
|
|
|
|
|
|
|
41
|
825
|
|
|
|
|
8718
|
return $got =~ $self->{+PATTERN}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |