line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Type::Tiny::Eq; |
2
|
2
|
|
|
2
|
|
40
|
use 5.008001; |
|
2
|
|
|
|
|
7
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
987
|
use parent qw( Type::Tiny ); |
|
2
|
|
|
|
|
623
|
|
|
2
|
|
|
|
|
13
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1043
|
sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } |
|
2
|
|
|
|
|
2257
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
12
|
|
|
12
|
1
|
27
|
my $class = shift; |
14
|
|
|
|
|
|
|
|
15
|
12
|
50
|
|
|
|
47
|
my %opts = ( @_ == 1 ) ? %{ $_[0] } : @_; |
|
0
|
|
|
|
|
0
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
_croak "Eq type constraints cannot have a parent constraint passed to the constructor" |
18
|
12
|
50
|
|
|
|
35
|
if exists $opts{parent}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
_croak "Eq type constraints cannot have a constraint coderef passed to the constructor" |
21
|
12
|
50
|
|
|
|
32
|
if exists $opts{constraint}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
_croak "Eq type constraints cannot have a inlining coderef passed to the constructor" |
24
|
12
|
50
|
|
|
|
29
|
if exists $opts{inlined}; |
25
|
|
|
|
|
|
|
|
26
|
12
|
50
|
|
|
|
25
|
_croak "Need to supply value" unless exists $opts{value}; |
27
|
|
|
|
|
|
|
|
28
|
12
|
100
|
|
|
|
40
|
_croak "Eq value must be defined" unless defined $opts{value}; |
29
|
|
|
|
|
|
|
|
30
|
10
|
|
|
|
|
97
|
$opts{value} = "$opts{value}"; # stringify |
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
47
|
return $class->SUPER::new( %opts ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
29
|
|
|
29
|
1
|
7179
|
sub value { $_[0]{value} } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _build_display_name { |
38
|
10
|
|
|
10
|
|
90
|
my $self = shift; |
39
|
10
|
|
|
|
|
21
|
sprintf( "Eq['%s']", $self->value ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub has_parent { |
43
|
6
|
|
|
6
|
1
|
6953
|
!!0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
10
|
|
33
|
10
|
1
|
6277
|
sub constraint { $_[0]{constraint} ||= $_[0]->_build_constraint } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build_constraint { |
49
|
10
|
|
|
10
|
|
19
|
my $self = shift; |
50
|
|
|
|
|
|
|
return sub { |
51
|
0
|
0
|
|
0
|
|
0
|
defined $_ && $_ eq $self->value; |
52
|
10
|
|
|
|
|
66
|
}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub can_be_inlined { |
56
|
18
|
|
|
18
|
1
|
13873
|
!!1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub inline_check { |
60
|
18
|
|
|
18
|
1
|
176
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
18
|
|
|
|
|
36
|
my $value = $self->value; |
63
|
18
|
|
|
|
|
54
|
my $code = "(defined($_[0]) && $_[0] eq '$value')"; |
64
|
|
|
|
|
|
|
|
65
|
18
|
50
|
|
|
|
55
|
return "do { $Type::Tiny::SafePackage $code }" |
66
|
|
|
|
|
|
|
if $Type::Tiny::AvoidCallbacks; ## no critic (Variables::ProhibitPackageVars) |
67
|
18
|
|
|
|
|
91
|
return $code; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |