- or download this
=head1 EXPORT
...
=cut
- or download this
=head1 SUBROUTINES
...
This function accepts a string or a list (range) and returns an array.
In the string form the accepted characters are: positive integers, dot
+s, commas and spaces. Every space will be removed.
- or download this
git-client> git status
...
[master a6dc557] initial POD to document validate function
1 file changed, 5 insertions(+), 6 deletions(-)
- or download this
# not allowed a lone .
croak "invalid range [$range] (single .)!" if $range =~ /[^.]+\.{1
+}[^.]+/;
# not allowed more than 2 .
croak "invalid range [$range] (more than 2 .)!" if $range =~ /[^.]
++\.{3}/;
- or download this
sub validate{
my $range;
...
return @range;
}
- or download this
note ("start checks about incorrect dots in string");
...
"expected to die with a lone dot";
- or download this
shell> prove -l -v ./t/01-validate.t
...
Files=1, Tests=5, 0 wallclock secs ( 0.06 usr + 0.03 sys = 0.09 CPU
+)
Result: PASS
- or download this
foreach my $string ( '1.2', '0..2,5.6,8', '1,2,.,3', '.' ){
dies_ok { Range::Validator::validate( $string ) }
"expected to die with a lone dot in range [$string]";
}
- or download this
shell> prove -l -v ./t/01-validate.t
...
Files=1, Tests=7, 0 wallclock secs ( 0.02 usr + 0.03 sys = 0.05 CPU
+)
Result: FAIL
- or download this
# not allowed a lone .
croak "invalid range [$range] (single .)!" if $range =~ /(?<!\.)\.
+(?!\.)/;
- or download this
foreach my $string ( '1.2', '0..2,5.6,8', '1,2,.,3', '.', '1.', '.1' )
+{
dies_ok { Range::Validator::validate( $string ) }
"expected to die with a lone dot in range [$string]";
}
- or download this
foreach my $newstring ( '1...3', '1,3...5','...', '1...', '...2' ){
dies_ok { Range::Validator::validate( $newstring ) }
"expected to die with three dots in range [$newstring]";
}
- or download this
shell> prove -l -v ./t/01-validate.t
...
Files=1, Tests=14, 1 wallclock secs ( 0.03 usr + 0.03 sys = 0.06 CP
+U)
Result: PASS
- or download this
sub validate{
my $range;
...
return @range;
}
- or download this
#!perl
use 5.006;
...
"expected to die with three dots in range [$newstring]";
}
- or download this
git-client> git status
...
5083ec3..169809c master -> master
- or download this
# spot reverse ranges like 27..5
if ($range =~ /[^.]\.\.[^.]/){
...
}
}
- or download this
# eval the range
@range = eval ($range);
...
@range = sort{ $a <=> $b } keys %single; # -- new line
return @range;
- or download this
sub validate{
my $range;
...
return @range;
}
- or download this
git-client> git log HEAD --oneline
...
49a0690 moved POD, removed -T
1788c12 module-starter created content
- or download this
foreach my $reversed ('3..1,7..9','1..4,7..5','3..4, 7..5','0..2,27..5
+'){
dies_ok { Range::Validator::validate( $reversed ) } "expected to d
+ie with reverse range [$reversed]";
}
- or download this
my %test = (
'1,1..3' => [(1,2,3)],
...
);
}
- or download this
ok 15 - expected to die with reverse range [3..1,7..9]
ok 16 - expected to die with reverse range [1..4,7..5]
...
ok 24 - correct result for range [8,9,1..2]
ok 25 - correct result for range [1..5,3]
- or download this
git-client> git log HEAD --oneline
...
--
*+ [master] test for overlappped or unordered ranges
- or download this
# otherwise we received a list
else{
...
}
- or download this
sub validate{
my $range;
...
return @range;
}
- or download this
Every string with occurences of a lone dot or more than two dots will
+be rejected causing an exception in the calling program.
Reverse ranges like in <code>'3..1'
- or download this
note ("starting test of list form");
...
);
}
- or download this
# all actions performed, no need to call our validate sub
actions_to_activate_account();
...
my @valid_range = Range::Validator::validate( @actions );
actions_to_activate_account( @valid_range );
- or download this
# assume we have a string if we receive only one argument
if ( @_ == 1){
...
}
- or download this
BUILD_REQUIRES => {
'Test::More' => '0',
...
'Capture::Tiny' => '0', # -- new line
},
- or download this
note ("test of warnings emitted");
{
...
like( $stderr, qr/^Empty list passed in/, "right warning for empty
+ list if \$Range::Validator::WARNINGS");
}
- or download this
=head1 ENABLE WARNINGS
If the <code>$Range::Validator::WARNINGS
- or download this
shell> prove ./t/manifest.t
...
Files=1, Tests=0, 0 wallclock secs ( 0.03 usr + 0.01 sys = 0.05 CPU
+)
Result: NOTESTS
- or download this
shell> prove ./t/manifest.t
...
# expected: 1
# The following files are not named in the MANIFEST file: .... # MANY
+ LINES MORE..
- or download this
shell> prove ./t/manifest.t
...
/path/to/your/module/xt/boilerplate.t
...
- or download this
shell> prove ./xt/boilerplate.t
...
Files=1, Tests=3, 1 wallclock secs ( 0.03 usr + 0.03 sys = 0.06 CPU
+)
Result: PASS
- or download this
shell> prove ./t/manifest.t
...
Files=1, Tests=1, 1 wallclock secs ( 0.02 usr + 0.03 sys = 0.05 CPU
+)
Result: PASS
- or download this
shell> prove -l -v ./t/pod.t
...
Files=1, Tests=1, 0 wallclock secs ( 0.03 usr + 0.02 sys = 0.05 CPU
+)
Result: PASS
- or download this
git-client> git log HEAD --oneline --reverse
...
e3feb61 removed xt/boilerplate.t
3c0da4f (HEAD -> master, YourGithubLogin/master) modified README
- or download this
package # hide from CPAN indexer
testhelper;
- or download this
use lib '.';
use t::testhelper;