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