| 1 | package Test::Proto::Repeatable; | ||
| 2 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | has 'contents', | ||
| 7 | is => 'rw', | ||
| 8 | 0 | ▶ | default => sub { Test::Proto::Series->new(@_) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 9 | |||
| 10 | has 'min', | ||
| 11 | is => 'rw', | ||
| 12 | 13 | ▶ | default => sub { 0 }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | has 'max', | ||
| 15 | is => 'rw', | ||
| 16 | 13 | ▶ | default => sub { undef }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | 5 | around 'min', 'max', 'contents' => \&Test::Proto::Common::chainable; | |
| 19 | |||
| 20 | 13 | ▶ | sub BUILDARGS { |
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 21 | 13 | my $class = shift; | |
| 22 | 13 | return { contents => Test::Proto::Series->new(@_) }; | |
| 23 | } | ||
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | Test::Proto::Repeatable - represent a repeatable element or series in array validation | ||
| 28 | |||
| 29 | =head1 SYNOPSIS | ||
| 30 | |||
| 31 | pArray->contains_only(pRepeatable('a', 'b')); | ||
| 32 | # will validate ['a', 'b'] and ['a', 'b', 'a', 'b'] as true | ||
| 33 | |||
| 34 | Used in array validation to represent a sequence qhich must be present in its entirety. Can contain, or be contained by, a L<Test::Proto::Series> or a L<Test::Proto::Alternation>. | ||
| 35 | |||
| 36 | =head1 METHODS | ||
| 37 | |||
| 38 | =head3 new | ||
| 39 | |||
| 40 | Each argument is another element in the series. NB: A series is automatically created to hold all the contents. | ||
| 41 | |||
| 42 | =head3 contents | ||
| 43 | |||
| 44 | die unless exists $alternation->contents->[0]; | ||
| 45 | |||
| 46 | A chainable getter/setter method for the contents of the series. | ||
| 47 | |||
| 48 | =head3 min | ||
| 49 | |||
| 50 | my $pRepeatable = pRepeatable('foo')->min(2); | ||
| 51 | my $min = $pRepeatable->min; | ||
| 52 | |||
| 53 | Sets and/or returns the minimum number of occurrences required. | ||
| 54 | |||
| 55 | =head3 max | ||
| 56 | |||
| 57 | my $pRepeatable = pRepeatable('foo')->max(2); | ||
| 58 | my $max = $pRepeatable->max; | ||
| 59 | |||
| 60 | Sets and/or returns the maximum number of occurrences permitted. | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | 5 | 1; | |