line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Proto::Alternation; |
2
|
5
|
|
|
5
|
|
5186
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1532
|
|
3
|
5
|
|
|
5
|
|
193
|
use warnings; |
|
5
|
|
|
|
|
178
|
|
|
5
|
|
|
|
|
523
|
|
4
|
5
|
|
|
5
|
|
24
|
use Moo; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'alternatives', |
7
|
|
|
|
|
|
|
is => 'rw', |
8
|
|
|
|
|
|
|
default => sub { [] }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub BUILDARGS { |
11
|
14
|
|
|
14
|
0
|
2310
|
my $class = shift; |
12
|
14
|
|
|
|
|
413
|
return { alternatives => [@_] }; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
around 'alternatives' => \&Test::Proto::Common::chainable; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Test::Proto::Alternation - represent an alternation in array validation |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
pArray->contains_only(pAlternation('a', pSeries('b', 'c'))); |
24
|
|
|
|
|
|
|
# will validate ['a'] and ['b', 'c'] as true |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Used in array validation to represent different options. Equivalent to C<|> in a regular expression. There is no limit to the number of alternatives which may be specified, but there must be at least one. This can handle nested L and L elements, and can be nested within them. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
For single-item alternation consider using C. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 new |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Each argument is a different alternative. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 alternatives |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
die unless exists $alternation->alternatives->[0]; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
A chainable getter/setter method for the different alternatives available to the alternation. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |