line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
2
|
|
|
2
|
|
1052
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
92
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use List::Util qw( all ); |
8
|
2
|
|
|
2
|
|
9
|
use Role::Tiny::With; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
101
|
|
9
|
2
|
|
|
2
|
|
9
|
use Specio::OO; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
87
|
|
10
|
2
|
|
|
2
|
|
12
|
use Storable qw( dclone ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
11
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
85
|
|
12
|
|
|
|
|
|
|
use Specio::Constraint::Role::Interface; |
13
|
2
|
|
|
2
|
|
12
|
with 'Specio::Constraint::Role::Interface'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1271
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
## no critic (Subroutines::ProtectPrivateSubs) |
17
|
|
|
|
|
|
|
my $attrs = dclone( Specio::Constraint::Role::Interface::_attrs() ); |
18
|
|
|
|
|
|
|
## use critic |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
for my $name (qw( _constraint _inline_generator )) { |
21
|
|
|
|
|
|
|
delete $attrs->{$name}{predicate}; |
22
|
|
|
|
|
|
|
$attrs->{$name}{init_arg} = undef; |
23
|
|
|
|
|
|
|
$attrs->{$name}{lazy} = 1; |
24
|
|
|
|
|
|
|
$attrs->{$name}{builder} |
25
|
|
|
|
|
|
|
= $name =~ /^_/ ? '_build' . $name : '_build_' . $name; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
delete $attrs->{parent}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
delete $attrs->{name}{predicate}; |
31
|
|
|
|
|
|
|
$attrs->{name}{lazy} = 1; |
32
|
|
|
|
|
|
|
$attrs->{name}{builder} = '_build_name'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$attrs->{of} = { |
35
|
|
|
|
|
|
|
isa => 'ArrayRef', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
40
|
|
|
|
|
|
|
return $attrs; |
41
|
|
|
|
|
|
|
} |
42
|
4
|
|
|
4
|
|
10
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
46
|
5
|
|
|
5
|
0
|
317
|
|
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
return defined $self->name; |
49
|
2
|
|
|
2
|
|
12
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $self = shift; |
52
|
11
|
|
|
11
|
|
19
|
|
53
|
11
|
|
|
|
|
33
|
return unless all { $_->_has_name } @{ $self->of }; |
54
|
|
|
|
|
|
|
return join q{ & }, map { $_->name } @{ $self->of }; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
3
|
|
19
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
58
|
|
|
|
|
|
|
my $self = shift; |
59
|
3
|
100
|
|
4
|
|
12
|
|
|
4
|
|
|
|
|
20
|
|
|
3
|
|
|
|
|
9
|
|
60
|
1
|
|
|
|
|
7
|
return !$self->_has_inline_generator; |
|
2
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
3
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
## use critic |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $_[0]->_optimized_constraint; |
65
|
20
|
|
|
20
|
|
33
|
} |
66
|
|
|
|
|
|
|
|
67
|
20
|
|
|
|
|
42
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## no critic (Subroutines::ProtectPrivateSubs) |
70
|
|
|
|
|
|
|
my @c = map { $_->_optimized_constraint } @{ $self->of }; |
71
|
|
|
|
|
|
|
return sub { |
72
|
3
|
|
|
3
|
|
54
|
return all { $_->( $_[0] ) } @c; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
5
|
|
|
5
|
|
39
|
my $self = shift; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
## no critic (Subroutines::ProtectPrivateSubs) |
79
|
5
|
|
|
|
|
12
|
return all { $_->_has_inline_generator } @{ $self->of }; |
|
10
|
|
|
|
|
522
|
|
|
5
|
|
|
|
|
19
|
|
80
|
|
|
|
|
|
|
} |
81
|
326
|
|
|
326
|
|
4154
|
|
|
346
|
|
|
|
|
2598
|
|
82
|
5
|
|
|
|
|
364
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return sub { |
85
|
|
|
|
|
|
|
return '(' . ( |
86
|
46
|
|
|
46
|
|
119
|
join q{ && }, |
87
|
|
|
|
|
|
|
map { sprintf( '( %s )', $_->_inline_generator->( $_, $_[1] ) ) } |
88
|
|
|
|
|
|
|
@{ $self->of } |
89
|
46
|
|
|
72
|
|
127
|
) . ')'; |
|
72
|
|
|
|
|
333
|
|
|
46
|
|
|
|
|
110
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
2
|
|
|
2
|
|
16
|
my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my %env; |
96
|
|
|
|
|
|
|
for my $type ( @{ $self->of } ) { |
97
|
|
|
|
|
|
|
%env = ( |
98
|
8
|
|
|
|
|
43
|
%env, |
99
|
4
|
|
|
4
|
|
27
|
%{ $type->inline_environment }, |
|
4
|
|
|
|
|
48
|
|
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
2
|
|
|
|
|
14
|
|
103
|
|
|
|
|
|
|
return \%env; |
104
|
|
|
|
|
|
|
} |
105
|
2
|
|
|
2
|
|
14
|
|
106
|
|
|
|
|
|
|
__PACKAGE__->_ooify; |
107
|
2
|
|
|
|
|
6
|
|
108
|
2
|
|
|
|
|
5
|
1; |
|
2
|
|
|
|
|
5
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# ABSTRACT: A class for intersection constraints |
111
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
14
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=pod |
114
|
|
|
|
|
|
|
|
115
|
2
|
|
|
|
|
14
|
=encoding UTF-8 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 NAME |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Specio::Constraint::Intersection - A class for intersection constraints |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 VERSION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
version 0.48 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SYNOPSIS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my $type = Specio::Constraint::Untion->new(...); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This is a specialized type constraint class for intersections, which will allow |
132
|
|
|
|
|
|
|
a value which matches each one of several distinct types. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=for Pod::Coverage parent |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 API |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This class provides all of the same methods as L<Specio::Constraint::Simple>, |
139
|
|
|
|
|
|
|
with a few differences: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 Specio::Constraint::Intersection->new( ... ) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The C<parent> parameter is ignored if it passed, as it is always C<undef> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The C<inline_generator> and C<constraint> parameters are also ignored. This |
146
|
|
|
|
|
|
|
class provides its own default inline generator subroutine reference. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Finally, this class requires an additional parameter, C<of>. This must be an |
149
|
|
|
|
|
|
|
arrayref of type objects. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 $union->of |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Returns an array reference of the individual types which makes up this |
154
|
|
|
|
|
|
|
intersection. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 ROLES |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This class does the L<Specio::Constraint::Role::Interface> and |
159
|
|
|
|
|
|
|
L<Specio::Role::Inlinable> roles. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SUPPORT |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SOURCE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This software is Copyright (c) 2012 - 2022 by Dave Rolsky. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is free software, licensed under: |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
The full text of the license can be found in the |
182
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |